madhrnek
madhrnek
FFilament
Created by Masea on 12/15/2023 in #❓┊help
how can i put script on a widget blade view?
Hi, I need help with uploading a file to a folder with a custom path. I would also like to store more information about the file such as size, disk used, mimetype, how can I map the data to be stored in the database for UploadFile? I have tried via action, but I would like to do it directly from the form: Tables\Actions\Action::make('upload_file')->label('Upload File') ->mutateFormDataUsing(function (array $data): array { $data['folder_id'] = $this->ownerRecord->id; $data['user_id'] = $this->ownerRecord->id; $data['disk'] = env('FILESYSTEM_DISK', 'public'); return $data; }) ->action(function (array $data, UserFolder $folder): void { $file = UserFile::create($data); $file->folder_id = $folder->id; $file->mimetype = Storage::disk('public')->mimeType($data['path']); $file->filesize = Storage::disk('public')->size($data['path']); $file->save(); }) ->form([ Forms\Components\TextInput::make('name')->required(), FileUpload::make('path') ->storeFileNamesIn('file_name') ->directory('/users/' . $this->ownerRecord->id . '/folders') ])
19 replies