spatie media User

Hi, I have a somewhat silly question but I must ask it because I'm stuck! I installed the Spatie media plugin. Everything went smoothly, I set up my 'form component' which contains only the option to upload, since I don't need anything else. I have also prepared my model as stipulated in the documentation. *I want each user to be able to have their own media library So, the model_type and model_id should correspond to my User model. But... the model_type and model_id are causing me serious issues. error: SQLSTATE[HY000]: General error: 1364 Field 'model_type' doesn't have a default value php Copy code SpatieMediaLibraryFileUpload::make('image') ->directory(function () { $userId = auth()->check() ? auth()->id() : 'default'; return 'user_uploads/' . $userId; }) ->multiple() ->reorderable() ->responsiveImages() ->disk('public') ]; Does anyone have the solution? Laravel 10 filament 3.2 spatie media 11
4 Replies
WessBechard
WessBechard8mo ago
If you're trying to attach uploads to a model, you're missing the steps where you add that connection. Check here. https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#setting-a-form-model
LeChatSoeur
LeChatSoeurOP8mo ago
But I am within a panel. Shouldn't this be done automatically?
WessBechard
WessBechard8mo ago
You're using a form on a panel correct?
Ramon.vV
Ramon.vV7mo ago
@WessBechard It literally says in the docs : 'The field will automatically load and save its uploads to your model. To set this functionality up, you must also follow the instructions set out in the setting a form model section. If you're using a panel, you can skip this step.' Shouldn't that mean exactly that, to skip that step? Having a similar problem as well.
Want results from more Discord servers?
Add your server