You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File::make(__('Attachment'), 'attachment')
->acceptedTypes('.pdf')
->disk('s3')
->path('ly/contents')
->store(function (Request $request, $model) {
$s3filePath = $request->attachment->store('ly/contents', 's3');
$model
->addMediaFromDisk($s3filePath, 's3')
->toMediaCollection('pdf');
return [
'attachment' => $s3filePath
];
})->onlyOnForms(),
# I have no attachment field in the database, so I use next fillFields function to fix this.
// https://github.com/laravel/nova-issues/issues/2334#issuecomment-709422756
protected static function fillFields(NovaRequest $request, $model, $fields)
{
$fillFields = parent::fillFields($request, $model, $fields);
// first element should be model object
$modelObject = $fillFields[0];
// remove all attributes do not have relevant columns in model table
unset($modelObject->attachment);
return $fillFields;
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: