78 lines
1.5 KiB
PHP
78 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Shift;
|
|
use App\Models\User;
|
|
use App\Policies\Concerns\ScopedByDepartment;
|
|
|
|
class ShiftPolicy
|
|
{
|
|
use ScopedByDepartment;
|
|
|
|
public function viewAny(User $user): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->canRead($user);
|
|
}
|
|
|
|
public function view(User $user, Shift $shift): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->canRead($user);
|
|
}
|
|
|
|
public function create(User $user): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasFullAccess($user);
|
|
}
|
|
|
|
public function update(User $user, Shift $shift): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasFullAccess($user);
|
|
}
|
|
|
|
public function delete(User $user, Shift $shift): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasFullAccess($user);
|
|
}
|
|
|
|
public function restore(User $user, Shift $shift): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasFullAccess($user);
|
|
}
|
|
|
|
public function forceDelete(User $user, Shift $shift): bool
|
|
{
|
|
if ($this->isSuperAdmin($user)) {
|
|
return true;
|
|
}
|
|
|
|
return $this->canForceDelete($user);
|
|
}
|
|
}
|