Resoures in the sub folders accessable by everyone
wikihadi opened this issue · comments
I agree, it's a nice Filament feature to have possibility to use sub folders for Models / Resources, but they won't work with Filament Shield when using subfolders... Any idea how to fix this ? thks
Hi
According to the changes of Laravel 11 (https://laravel.com/docs/11.x/authorization#manually-registering-policies) and also the documentation of this package (https://github.com/bezhanSalleh/filament-shield?tab=readme-ov-file#custom-folder-structure-for-models-or-third-party-plugins)
, to fix the problem:
Should manually register policies and their corresponding models within the boot
method of your application's AppServiceProvider
:
use App\Models\Order;
use App\Policies\OrderPolicy;
use Illuminate\Support\Facades\Gate;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Gate::policy(Order::class, OrderPolicy::class);
}