Spatie Media Library custom file name
Is there a way to change the file name with an input text or a way to add some custom description?
2 Replies
hey, @yaroslavpopovic , did you find a solution for this?
This is how I did it in one of my project. ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file, Get $get): string {
$rec = $this->getOwnerRecord();
$name = (string) 'image-of-'. $rec->slug . '-' . Str::random(4). '.' . $file->getClientOriginalExtension();
return $name;
})