Given the Nova class
class Article extends Resource
{
// [...]
public function fields(Request $request)
{
return [
ID::make()
->sortable(),
Image::make('Image', 'filename')
->disk('public')
->path('articles')
->prunable(),
];
}
// [...]
}
Why do I get this error when I upload an image?
SQLSTATE[HY000]: General error: 1364 Field 'filename' doesn't have a default value (SQL: insert into `article` (`id`, `updated_at`, `created_at`) values (143, 2021-06-07 12:35:36, 2021-06-07 12:35:36))
Some images can be uploaded, others don't. It's not due to their filetype, as some .png works but other don't.
This error message is misleading. The problem is the file size: when it's bigger than 3MB, it will throw this error.
I suggest to add a help message on the field itself until Laravel Nova use a clearer message, like so:
Image::make('Image', 'filename')
->disk('public')
->path('teacher_images/source')
->prunable()
->help('Size: 3MB maximum')