base commit
This commit is contained in:
77
app/Policies/PositionPolicy.php
Normal file
77
app/Policies/PositionPolicy.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Position;
|
||||
use App\Models\User;
|
||||
use App\Policies\Concerns\ScopedByDepartment;
|
||||
|
||||
class PositionPolicy
|
||||
{
|
||||
use ScopedByDepartment;
|
||||
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
if ($this->isSuperAdmin($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->canRead($user);
|
||||
}
|
||||
|
||||
public function view(User $user, Position $position): 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, Position $position): bool
|
||||
{
|
||||
if ($this->isSuperAdmin($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->hasFullAccess($user);
|
||||
}
|
||||
|
||||
public function delete(User $user, Position $position): bool
|
||||
{
|
||||
if ($this->isSuperAdmin($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->hasFullAccess($user);
|
||||
}
|
||||
|
||||
public function restore(User $user, Position $position): bool
|
||||
{
|
||||
if ($this->isSuperAdmin($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->hasFullAccess($user);
|
||||
}
|
||||
|
||||
public function forceDelete(User $user, Position $position): bool
|
||||
{
|
||||
if ($this->isSuperAdmin($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->canForceDelete($user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user