saade / filament-fullcalendar

The Most Popular JavaScript Calendar as a Filament Widget
MIT License
295 stars 88 forks source link

fix resolving the model #154

Closed atmonshi closed 9 months ago

atmonshi commented 10 months ago

in some cases, need to get the model dynamically or conditionally, so I am using the method:

public function getModel(): ?string
{
    return myMode::class;
}

I'll get the error: Class name must be a valid object or a string

raised from:

protected function getEloquentQuery(): Builder
{
    $query = $this->model::query(); //error

    // TODO: Scope query to tenant.

    return $query;
}

the solution will be to access the model from the getter or resolve it by the container

protected function getEloquentQuery(): Builder
{
    $query = app($this->getModel())::query(); //fix

    // TODO: Scope query to tenant.

    return $query;
}
saade commented 9 months ago

Thanks, InteractsWithRecord is clashing with the Filament one rn, i need to refactor and probably launch a new major to fix it.