When disabling a global scope, does a model policy that uses eloquent take priority?

I have a Post model that has a global scope PostPublishedScope applied. It does literally what the name says:
$builder->where( 'published', '=', true)
->where('published_at', '<>', null)
->where('published_at', '<', now());
$builder->where( 'published', '=', true)
->where('published_at', '<>', null)
->where('published_at', '<', now());
I have a PostPolicy that checks these 2 conditions together: $user->exists() and $post->exists() on several actions. In Filament, I also used the recommended method to disable the PostPublishedScope:
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->withoutGlobalScope(PostPublishedScope::class);
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->withoutGlobalScope(PostPublishedScope::class);
}
On my table, I also have these standard Filament actions:
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
This used to do what I expected: list my posts in the admin panel, let me view, edit and delete them. Now what it does: 1. Lists all posts in admin panel. 2. Does not let me use the CRUD actions above. The actions no longer show, and the routes for them return a 403 Forbidden error. But if I have at least 1 post that's publiished, those actions do show up in the table for all of them. So...I'm really confused. Does this sound like a bug I should report?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?