Hide a resource widget based on the resource status

Hey everyone. I found the option to hide a widget on a resource with this function:

public static function canView(): bool

The issue is that I want to only show the widget if the resource record/model is in a certain status. But I can't access the record because the function is static. Does anyone know a workaround?

What I would like to do but doesn't work:

class Availability extends Widget
{
    public ?Model $record = null;

    public static function canView(): bool
    {
        return $this->record->status === StatusEnum::Request;
    }
}


Something that feels hacky that works:

$record = Event::find(Route::current()->parameter('record'));
return $record->status === StatusEnum::Request;
Was this page helpful?