Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Cushty's avatar
Level 4

spatie media library Wizard

hi I am using Spatie media library and getting the error other have got here, 'avatar_id' doesn't have a default value, I saw that I need to add the model to the form via the docs but I am a bit confused where to add this as I have a create page for the wizard. so it's not encapsulated by a form.

  1. Where do I add it to the create page with wizard?
  2. I am a bit confused why I have a separate create page for the wizard but still a normal resource with a form (It may be for editing reasons), I know I'm being dumb but I do not understand fully.

Thanks

0 likes
3 replies
antoineLZCH's avatar

So you want to use Spatie's Media Library with a wizard. Here's what you can do: just inject the model into your wizard's create page and associate the media with it. For example:

You would do something like this: public function create(User $user) { $user->addMedia($request->file('avatar'))->toMediaCollection('avatar'); }

That should solve your problem!

Cushty's avatar
Level 4

@antoineLZCH Hi, thanks for the reply PHP Storm is squeaking

Declaration must be compatible with CreateRecord->create([another: bool = false]) 
$request: \App\Filament\Resources\ApplicationResource\Pages\Request

Ive searched the docs and google and no one is talking about using Spatie in a wizard. Thanks

Cushty's avatar
Level 4

its ok i had a spatie foreign id column :( cant believe I did that lol, all working now

Please or to participate in this conversation.