Files
ismailmasseran b05e074456 Feature/phone register (#11)
Co-authored-by: ISMAIL MASSERAN <topaz@ISMAILs-Macbook.local>
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local>
Reviewed-on: #11
2026-07-14 12:03:22 +08:00

76 lines
1.8 KiB
PHP

<?php
namespace Modules\User\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use Modules\Auth\Entities\User;
class UserPolicy
{
use HandlesAuthorization;
public const PERMISSION_VIEW = 'lihat pengguna';
public const PERMISSION_CREATE = 'daftar pengguna baru';
public const PERMISSION_UPDATE = 'kemaskini pengguna';
public const PERMISSION_DELETE = 'padam akaun pengguna';
/**
* Determine whether the user can view any models.
*/
public function viewAny($user): bool
{
return $user->hasPermissionTo(self::PERMISSION_VIEW);
}
/**
* Determine whether the user can view the model.
*/
public function view($user, ?User $userModel = null): bool
{
return $user->hasPermissionTo(self::PERMISSION_VIEW);
}
/**
* Determine whether the user can create models.
*/
public function create($user): bool
{
return $user->hasPermissionTo(self::PERMISSION_CREATE);
}
/**
* Determine whether the user can update the model.
*/
public function update($user, ?User $userModel = null): bool
{
return $user->hasPermissionTo(self::PERMISSION_UPDATE);
}
/**
* Determine whether the user can delete any model.
*/
public function deleteAny($user): bool
{
return $user->hasPermissionTo(self::PERMISSION_DELETE);
}
/**
* Determine whether the user can delete the model.
*/
public function delete($user, ?User $userModel = null): bool
{
return $user->hasPermissionTo(self::PERMISSION_DELETE);
}
/**
* Determine whether the user can restore a soft-deleted model.
*/
public function restore($user, ?User $userModel = null): bool
{
return $user->hasPermissionTo(self::PERMISSION_DELETE);
}
}