Internal enhancements to system registration and editing

This commit is contained in:
Deon George
2022-01-02 01:52:21 +11:00
parent fa2ac9a656
commit afaa7d8bc7
12 changed files with 235 additions and 87 deletions

View File

@@ -10,6 +10,22 @@ class SystemPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can create the model.
*
* A user can create a system if it doesnt exist.
*
* @param User $user
* @param System $system
* @return bool
*/
public function create(User $user, System $system): bool
{
// Site Admins can always create
// If it doesnt exist, then a user can create it.
return ($user->isAdmin() || (! $system->exists));
}
/**
* Determine whether the user can update the model.
*
@@ -17,9 +33,9 @@ class SystemPolicy
* If it has addresses, at least one of the addresses must have been validated.
* (The assumption is, if a system has multiple addresses, they would be valid, or an admin can remove them.)
*
* @param \App\Models\User $user
* @param \App\Models\System $system
* @return \Illuminate\Auth\Access\Response|bool
* @param User $user
* @param System $system
* @return bool
*/
public function update(User $user, System $system): bool
{