Accessing Model /ResourceIn Widget

I know this has been asked a lot, and I have done a lot of searching trying to figure this out but for some reason I cannot access the Model when I am on a View Page. I have tried:
use Illuminate\Database\Eloquent\Model;

public ?Model $record = null;
use Illuminate\Database\Eloquent\Model;

public ?Model $record = null;
to no avail. It always responds with an error saying 'Attempt to read property "name" on null'. If I remove the = null portion I get an error saying I can't access the variable before it is initialized. I have created a very basic widget using the CLI and run into the same issues even when starting from scratch. Could really use some help here, I am stumped at this point.
1 Reply
luciano.mizra
luciano.mizra3mo ago
Filament components are an extension of Livewire components, as always you have the corresponding hooks available: https://livewire.laravel.com/docs/lifecycle-hooks For example you could use mount: public function mount(): void { $this->model = Model::class; }
Laravel
Lifecycle Hooks | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Want results from more Discord servers?
Add your server