F
Filament12mo ago
krkmo

How to dynamically change the FileUpload directory field ?

I need to store the documents in subfolder with the user name in the Storage for example: storage/public/Noah storage/public/James storage/public/Sophia FileUpload::make('name_file')->disk('public')->directory('username') I have not been able to do it
2 Replies
Andrew Wallo
Andrew Wallo12mo ago
I suppose you can just do this:
use Illuminate\Support\Facades\Auth;
//
FileUpload::make('name_file')
->disk('public')
->directory(static fn() => Auth::user()->name), // or username or whatever
use Illuminate\Support\Facades\Auth;
//
FileUpload::make('name_file')
->disk('public')
->directory(static fn() => Auth::user()->name), // or username or whatever
krkmo
krkmoOP12mo ago
thanks
Want results from more Discord servers?
Add your server