saade / filament-fullcalendar

The Most Popular JavaScript Calendar as a Filament Widget
MIT License
282 stars 85 forks source link

fix resolving the model #154

Closed atmonshi closed 8 months ago

atmonshi commented 8 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 8 months ago

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