28 lines
707 B
PHP
28 lines
707 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Enums\RoleEnum;
|
|
use App\Models\Car;
|
|
use App\Models\User;
|
|
|
|
class CarPolicy
|
|
{
|
|
public function create(User $user, User $carUser)
|
|
{
|
|
return $user->warehouse_id == $carUser->warehouse->id &&
|
|
($user->role == RoleEnum::DISPATCHER || $user->role == RoleEnum::ADMIN);
|
|
}
|
|
|
|
public function update(User $user, Car $car)
|
|
{
|
|
return $user->warehouse_id == $car->user->warehouse_id &&
|
|
($user->role == RoleEnum::DISPATCHER || $user->role == RoleEnum::ADMIN);
|
|
}
|
|
|
|
public function delete(User $user, Car $car)
|
|
{
|
|
return $user->warehouse_id == $car->user->warehouse_id && $user->role == RoleEnum::ADMIN;
|
|
}
|
|
}
|