26 lines
552 B
PHP
26 lines
552 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Policies;
|
||
|
|
||
|
use App\Enums\RoleEnum;
|
||
|
use App\Models\User;
|
||
|
use App\Models\Warehouse;
|
||
|
|
||
|
class WarehousePolicy
|
||
|
{
|
||
|
public function update(User $user, Warehouse $warehouse)
|
||
|
{
|
||
|
return $warehouse->id == $user->warehouse_id && $user->role == RoleEnum::ADMIN;
|
||
|
}
|
||
|
|
||
|
public function create(User $user)
|
||
|
{
|
||
|
return $user->role == RoleEnum::ADMIN;
|
||
|
}
|
||
|
|
||
|
public function delete(User $user, Warehouse $warehouse)
|
||
|
{
|
||
|
return $warehouse->id == $user->warehouse_id && $user->role == RoleEnum::ADMIN;
|
||
|
}
|
||
|
}
|