JSn1nj4
JSn1nj4
FFilament
Created by JSn1nj4 on 4/29/2025 in #❓┊help
When disabling a global scope, do model policies undo that?
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?
4 replies
FFilament
Created by JSn1nj4 on 8/5/2023 in #❓┊help
Change in `afterStateUpdated()` hook for file uploads?
I have an Image model I'm saving extra data for on upload. In v2, I got this working using the afterStateUpdated() hook: https://github.com/JSn1nj4/ElliotDerhay.com/blob/feature/125-dashboard-overhaul-with-filament/app/Filament/Resources/ImageResource/Pages/CreateImage.php#L27 Reading this other help thread is what got me there: https://discord.com/channels/883083792112300104/1130866560848892015 This worked out so well because the second param was a TemporaryUploadedFile. It had everything I needed to fill the other fields and locate the file. Now I'm v3, that second param is just a filename string and I'm having difficulty locating the actual file. What's the best way to get file info for uploads now?
8 replies