Store Original File Name

storeOriginalFileName

The storeOriginalFileName function on the Attachment is used to enable or disable the storage of the original name of uploaded files in the database.

Since files may be stored with custom file names based on your preferred naming method, storing the original file name in the database can be beneficial for displaying it in your application's UI or elsewhere.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Mostafaznv\Larupload\Storage\Attachment;
use Mostafaznv\Larupload\Traits\Larupload;

class Media extends Model
{
    use Larupload;

    public function attachments(): array
    {
        return [
            Attachment::make('file')->storeOriginalFileName(true)
        ];
    }
}

This feature has been available since version 2.2.0

Last updated