feat: Implement authorization for various models and widgets by creating policies, updating the Shield seeder, and adding widget shields.
This commit is contained in:
parent
1a345f2759
commit
2400f686a6
@ -3,17 +3,18 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\EggCollection;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasWidgetShield;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class EggProductionChart extends ChartWidget
|
||||
{
|
||||
use HasWidgetShield;
|
||||
|
||||
protected ?string $heading = 'Trend Produksi Telur (30 Hari Terakhir)';
|
||||
|
||||
protected static ?int $sort = 2;
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$data = EggCollection::where('production_date', '>=', now()->subDays(30))
|
||||
|
||||
@ -3,11 +3,14 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Order;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasWidgetShield;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class OrderTrendChart extends ChartWidget
|
||||
{
|
||||
use HasWidgetShield;
|
||||
|
||||
protected ?string $heading = 'Trend Jumlah Pesanan (30 Hari Terakhir)';
|
||||
|
||||
protected static ?int $sort = 4;
|
||||
|
||||
@ -5,18 +5,19 @@
|
||||
use App\Models\Expense;
|
||||
use App\Models\FeedPurchase;
|
||||
use App\Models\Order;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasWidgetShield;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RevenueExpenseChart extends ChartWidget
|
||||
{
|
||||
use HasWidgetShield;
|
||||
|
||||
protected ?string $heading = 'Pendapatan vs Pengeluaran (6 Bulan Terakhir)';
|
||||
|
||||
protected static ?int $sort = 3;
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$months = collect(range(5, 0))->reverse()->map(function ($i) {
|
||||
|
||||
@ -10,11 +10,14 @@
|
||||
use App\Models\Expense;
|
||||
use App\Models\FeedPurchase;
|
||||
use App\Models\Order;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasWidgetShield;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class StatsOverview extends BaseWidget
|
||||
{
|
||||
use HasWidgetShield;
|
||||
|
||||
protected static ?int $sort = 1;
|
||||
|
||||
protected function getStats(): array
|
||||
|
||||
@ -3,11 +3,14 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Order;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasWidgetShield;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TopCustomersChart extends ChartWidget
|
||||
{
|
||||
use HasWidgetShield;
|
||||
|
||||
protected ?string $heading = 'Top 5 Pelanggan (Berdasarkan Total Order)';
|
||||
|
||||
protected static ?int $sort = 6;
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\RoleEnum;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -11,7 +13,7 @@
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
use HasFactory, HasRoles, Notifiable, SoftDeletes;
|
||||
|
||||
@ -35,4 +37,9 @@ protected function withoutDeveloper(Builder $query): void
|
||||
$q->where('name', RoleEnum::DEVELOPER);
|
||||
});
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
69
app/Policies/ChickenPolicy.php
Normal file
69
app/Policies/ChickenPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Chicken;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class ChickenPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Chicken');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('View:Chicken');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Chicken');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('Update:Chicken');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('Delete:Chicken');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('Restore:Chicken');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Chicken');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Chicken');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Chicken');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Chicken $chicken): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Chicken');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Chicken');
|
||||
}
|
||||
}
|
||||
69
app/Policies/CustomerPolicy.php
Normal file
69
app/Policies/CustomerPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class CustomerPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Customer');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('View:Customer');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Customer');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Update:Customer');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Delete:Customer');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Restore:Customer');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Customer');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Customer');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Customer');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Customer');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Customer');
|
||||
}
|
||||
}
|
||||
69
app/Policies/DelayedGoodPolicy.php
Normal file
69
app/Policies/DelayedGoodPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\DelayedGood;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class DelayedGoodPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:DelayedGood');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('View:DelayedGood');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:DelayedGood');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('Update:DelayedGood');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('Delete:DelayedGood');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('Restore:DelayedGood');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:DelayedGood');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:DelayedGood');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:DelayedGood');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, DelayedGood $delayedGood): bool
|
||||
{
|
||||
return $authUser->can('Replicate:DelayedGood');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:DelayedGood');
|
||||
}
|
||||
}
|
||||
69
app/Policies/EggCollectionPolicy.php
Normal file
69
app/Policies/EggCollectionPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\EggCollection;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class EggCollectionPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:EggCollection');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('View:EggCollection');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:EggCollection');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('Update:EggCollection');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('Delete:EggCollection');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('Restore:EggCollection');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:EggCollection');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:EggCollection');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:EggCollection');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, EggCollection $eggCollection): bool
|
||||
{
|
||||
return $authUser->can('Replicate:EggCollection');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:EggCollection');
|
||||
}
|
||||
}
|
||||
69
app/Policies/EggPricePolicy.php
Normal file
69
app/Policies/EggPricePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\EggPrice;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class EggPricePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:EggPrice');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('View:EggPrice');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:EggPrice');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('Update:EggPrice');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('Delete:EggPrice');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('Restore:EggPrice');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:EggPrice');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:EggPrice');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:EggPrice');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, EggPrice $eggPrice): bool
|
||||
{
|
||||
return $authUser->can('Replicate:EggPrice');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:EggPrice');
|
||||
}
|
||||
}
|
||||
69
app/Policies/ExpensePolicy.php
Normal file
69
app/Policies/ExpensePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class ExpensePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Expense');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('View:Expense');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Expense');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('Update:Expense');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('Delete:Expense');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('Restore:Expense');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Expense');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Expense');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Expense');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Expense $expense): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Expense');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Expense');
|
||||
}
|
||||
}
|
||||
69
app/Policies/FeedPolicy.php
Normal file
69
app/Policies/FeedPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Feed;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class FeedPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Feed');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('View:Feed');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Feed');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('Update:Feed');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('Delete:Feed');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('Restore:Feed');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Feed');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Feed');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Feed');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Feed $feed): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Feed');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Feed');
|
||||
}
|
||||
}
|
||||
69
app/Policies/FeedPurchasePolicy.php
Normal file
69
app/Policies/FeedPurchasePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\FeedPurchase;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class FeedPurchasePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:FeedPurchase');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('View:FeedPurchase');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:FeedPurchase');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('Update:FeedPurchase');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('Delete:FeedPurchase');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('Restore:FeedPurchase');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:FeedPurchase');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:FeedPurchase');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:FeedPurchase');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, FeedPurchase $feedPurchase): bool
|
||||
{
|
||||
return $authUser->can('Replicate:FeedPurchase');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:FeedPurchase');
|
||||
}
|
||||
}
|
||||
69
app/Policies/OrderPolicy.php
Normal file
69
app/Policies/OrderPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class OrderPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Order');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('View:Order');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Order');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('Update:Order');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('Delete:Order');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('Restore:Order');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Order');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Order');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Order');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Order $order): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Order');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Order');
|
||||
}
|
||||
}
|
||||
69
app/Policies/RolePolicy.php
Normal file
69
app/Policies/RolePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RolePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Role');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('View:Role');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Role');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Update:Role');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Delete:Role');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Restore:Role');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Role');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Role');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Role');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Role');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Role');
|
||||
}
|
||||
}
|
||||
69
app/Policies/UnitPolicy.php
Normal file
69
app/Policies/UnitPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Unit;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class UnitPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Unit');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('View:Unit');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Unit');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('Update:Unit');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('Delete:Unit');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('Restore:Unit');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Unit');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Unit');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Unit');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Unit $unit): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Unit');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Unit');
|
||||
}
|
||||
}
|
||||
66
app/Policies/UserPolicy.php
Normal file
66
app/Policies/UserPolicy.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class UserPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:User');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('View:User');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:User');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Update:User');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Delete:User');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Restore:User');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:User');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:User');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:User');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Replicate:User');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:User');
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,157 @@ public function run(): void
|
||||
{
|
||||
"name": "Developer",
|
||||
"guard_name": "web",
|
||||
"permissions" : []
|
||||
"permissions" : [
|
||||
"View:StatsOverview",
|
||||
"View:EggProductionChart",
|
||||
"View:OrderTrendChart",
|
||||
"View:RevenueExpenseChart",
|
||||
"View:TopCustomersChart",
|
||||
|
||||
"ViewAny:Chcicken",
|
||||
"View:Chcicken",
|
||||
"Create:Chcicken",
|
||||
"Update:Chcicken",
|
||||
"Delete:Chcicken",
|
||||
"Restore:Chcicken",
|
||||
"ForceDelete:Chcicken",
|
||||
"ForceDeleteAny:Chcicken",
|
||||
"RestoreAny:Chcicken",
|
||||
"Replicate:Chcicken",
|
||||
"Reorder:Chcicken",
|
||||
|
||||
"ViewAny:Customer",
|
||||
"View:Customer",
|
||||
"Create:Customer",
|
||||
"Update:Customer",
|
||||
"Delete:Customer",
|
||||
"Restore:Customer",
|
||||
"ForceDelete:Customer",
|
||||
"ForceDeleteAny:Customer",
|
||||
"RestoreAny:Customer",
|
||||
"Replicate:Customer",
|
||||
"Reorder:Customer",
|
||||
|
||||
"ViewAny:DelayedGood",
|
||||
"View:DelayedGood",
|
||||
"Create:DelayedGood",
|
||||
"Update:DelayedGood",
|
||||
"Delete:DelayedGood",
|
||||
"Restore:DelayedGood",
|
||||
"ForceDelete:DelayedGood",
|
||||
"ForceDeleteAny:DelayedGood",
|
||||
"RestoreAny:DelayedGood",
|
||||
"Replicate:DelayedGood",
|
||||
"Reorder:DelayedGood",
|
||||
|
||||
"ViewAny:EggCollection",
|
||||
"View:EggCollection",
|
||||
"Create:EggCollection",
|
||||
"Update:EggCollection",
|
||||
"Delete:EggCollection",
|
||||
"Restore:EggCollection",
|
||||
"ForceDelete:EggCollection",
|
||||
"ForceDeleteAny:EggCollection",
|
||||
"RestoreAny:EggCollection",
|
||||
"Replicate:EggCollection",
|
||||
"Reorder:EggCollection",
|
||||
|
||||
"ViewAny:EggPrice",
|
||||
"View:EggPrice",
|
||||
"Create:EggPrice",
|
||||
"Update:EggPrice",
|
||||
"Delete:EggPrice",
|
||||
"Restore:EggPrice",
|
||||
"ForceDelete:EggPrice",
|
||||
"ForceDeleteAny:EggPrice",
|
||||
"RestoreAny:EggPrice",
|
||||
"Replicate:EggPrice",
|
||||
"Reorder:EggPrice",
|
||||
|
||||
"ViewAny:Expense",
|
||||
"View:Expense",
|
||||
"Create:Expense",
|
||||
"Update:Expense",
|
||||
"Delete:Expense",
|
||||
"Restore:Expense",
|
||||
"ForceDelete:Expense",
|
||||
"ForceDeleteAny:Expense",
|
||||
"RestoreAny:Expense",
|
||||
"Replicate:Expense",
|
||||
"Reorder:Expense",
|
||||
|
||||
"ViewAny:Feed",
|
||||
"View:Feed",
|
||||
"Create:Feed",
|
||||
"Update:Feed",
|
||||
"Delete:Feed",
|
||||
"Restore:Feed",
|
||||
"ForceDelete:Feed",
|
||||
"ForceDeleteAny:Feed",
|
||||
"RestoreAny:Feed",
|
||||
"Replicate:Feed",
|
||||
"Reorder:Feed",
|
||||
|
||||
"ViewAny:FeedPurchase",
|
||||
"View:FeedPurchase",
|
||||
"Create:FeedPurchase",
|
||||
"Update:FeedPurchase",
|
||||
"Delete:FeedPurchase",
|
||||
"Restore:FeedPurchase",
|
||||
"ForceDelete:FeedPurchase",
|
||||
"ForceDeleteAny:FeedPurchase",
|
||||
"RestoreAny:FeedPurchase",
|
||||
"Replicate:FeedPurchase",
|
||||
"Reorder:FeedPurchase",
|
||||
|
||||
"ViewAny:OrderPurchase",
|
||||
"View:OrderPurchase",
|
||||
"Create:OrderPurchase",
|
||||
"Update:OrderPurchase",
|
||||
"Delete:OrderPurchase",
|
||||
"Restore:OrderPurchase",
|
||||
"ForceDelete:OrderPurchase",
|
||||
"ForceDeleteAny:OrderPurchase",
|
||||
"RestoreAny:OrderPurchase",
|
||||
"Replicate:OrderPurchase",
|
||||
"Reorder:OrderPurchase",
|
||||
|
||||
"ViewAny:Order",
|
||||
"View:Order",
|
||||
"Create:Order",
|
||||
"Update:Order",
|
||||
"Delete:Order",
|
||||
"Restore:Order",
|
||||
"ForceDelete:Order",
|
||||
"ForceDeleteAny:Order",
|
||||
"RestoreAny:Order",
|
||||
"Replicate:Order",
|
||||
"Reorder:Order",
|
||||
|
||||
"ViewAny:Unit",
|
||||
"View:Unit",
|
||||
"Create:Unit",
|
||||
"Update:Unit",
|
||||
"Delete:Unit",
|
||||
"Restore:Unit",
|
||||
"ForceDelete:Unit",
|
||||
"ForceDeleteAny:Unit",
|
||||
"RestoreAny:Unit",
|
||||
"Replicate:Unit",
|
||||
"Reorder:Unit",
|
||||
|
||||
"ViewAny:User",
|
||||
"View:User",
|
||||
"Create:User",
|
||||
"Update:User",
|
||||
"Delete:User",
|
||||
"Restore:User",
|
||||
"ForceDelete:User",
|
||||
"ForceDeleteAny:User",
|
||||
"RestoreAny:User",
|
||||
"Replicate:User",
|
||||
"Reorder:User"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Pemilik",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user