Storing multiple filenames at once when uploading multiple files

I'm trying to save multiple attachements at once and store their filenames also, so as docs say I use https://filamentphp.com/docs/3.x/forms/fields/file-upload#storing-original-file-names-independently and on my model

protected $casts = [ 'filename' => 'array', ];

However, this results in all filenames being stored under filename column instead each filename for each attachement.

I did find a workaround by manually updating filename with after() method on CreateAction, but is there a better more straightforward way of doing this?:

CreateAction::make()->after(function ($record, $data) { foreach($data['url'] as $url) { $asset = Asset::where('url', $url)->first(); $asset->filename = $data['filename'][$url]; $asset->save(); } })
image.png
image.png
Was this page helpful?