feat: Implement policy classes for Category, Contact, and Visitor with authorization methods
This commit is contained in:
parent
926d25d6cf
commit
57ed5e3cda
@ -9,6 +9,7 @@
|
||||
use App\Models\VerificationRequest;
|
||||
use App\Models\VerificationReview;
|
||||
use BackedEnum;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
@ -23,7 +24,7 @@
|
||||
|
||||
class AdminVerification extends Page implements HasActions, HasForms
|
||||
{
|
||||
use InteractsWithActions, InteractsWithForms;
|
||||
use HasPageShield, InteractsWithActions, InteractsWithForms;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Settings\GeneralSettings;
|
||||
use BackedEnum;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@ -16,6 +17,8 @@
|
||||
|
||||
class ManageGeneralSettings extends SettingsPage
|
||||
{
|
||||
use HasPageShield;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Cog6Tooth;
|
||||
|
||||
protected static string $settings = GeneralSettings::class;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Settings\SeoSettings;
|
||||
use BackedEnum;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\SettingsPage;
|
||||
@ -14,6 +15,8 @@
|
||||
|
||||
class ManageSeoSettings extends SettingsPage
|
||||
{
|
||||
use HasPageShield;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::MagnifyingGlass;
|
||||
|
||||
protected static string $settings = SeoSettings::class;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Settings\SocialMediaSettings;
|
||||
use BackedEnum;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
@ -14,6 +15,8 @@
|
||||
|
||||
class ManageSocialMediaSettings extends SettingsPage
|
||||
{
|
||||
use HasPageShield;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Share;
|
||||
|
||||
protected static string $settings = SocialMediaSettings::class;
|
||||
|
||||
69
app/Policies/CategoryPolicy.php
Normal file
69
app/Policies/CategoryPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class CategoryPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Category');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('View:Category');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Category');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('Update:Category');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('Delete:Category');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('Restore:Category');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Category');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Category');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Category');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Category $category): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Category');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Category');
|
||||
}
|
||||
}
|
||||
69
app/Policies/ContactPolicy.php
Normal file
69
app/Policies/ContactPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class ContactPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Contact');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('View:Contact');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Contact');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('Update:Contact');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('Delete:Contact');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('Restore:Contact');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Contact');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Contact');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Contact');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Contact $contact): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Contact');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Contact');
|
||||
}
|
||||
}
|
||||
69
app/Policies/VisitorPolicy.php
Normal file
69
app/Policies/VisitorPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Visitor;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class VisitorPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Visitor');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('View:Visitor');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Visitor');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('Update:Visitor');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('Delete:Visitor');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('Restore:Visitor');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Visitor');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Visitor');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Visitor');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Visitor $visitor): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Visitor');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Visitor');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user