bezhanSalleh / filament-shield

The easiest and most intuitive way to add access management to your Filament Admin Resources, Pages & Widgets through `spatie/laravel-permission`
MIT License
1.35k stars 166 forks source link

Resoures in the sub folders accessable by everyone #390

Open wikihadi opened 2 months ago

wikihadi commented 2 months ago

Resoures in the sub folders accessable by everyone Screenshot 2024-05-30 010932 داشبوردا

breizhwave commented 1 month ago

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

AnasSharif commented 1 month ago

I also agree with you in filament docus they mentionds for subdirectories path used AuthServiceProvider but in laravel 11 there's not AuthServiceProvider class.

Screenshot 2024-06-13 at 1 13 17 AM
yeganehha commented 4 weeks ago

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);
}