2023-10-06 15:00:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Policies\Rules\UserStaticRules;
|
|
|
|
|
|
|
|
|
|
class UserPolicy
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view any models.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function viewAny(User $authUser): bool
|
|
|
|
|
{
|
2025-07-28 09:46:22 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function view(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can create models.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function create(User $authUser): bool
|
|
|
|
|
{
|
2025-07-28 09:46:22 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can update the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function update(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can delete the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function delete(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can restore the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function restore(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can permanently delete the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return booleanean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function forceDelete(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can duplicate the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return booleanean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function duplicate(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can publish/unpublish the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @return booleanean
|
|
|
|
|
*/
|
2025-10-16 16:20:47 +02:00
|
|
|
public function changePublished(User $authUser): bool
|
2023-10-06 15:00:42 +02:00
|
|
|
{
|
2025-10-16 16:20:47 +02:00
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|
2025-10-07 10:12:23 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can update associated brands to the model.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\User $authUser
|
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @return booleanean
|
|
|
|
|
*/
|
|
|
|
|
public function changeBrands(User $authUser, User $user): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) &&
|
|
|
|
|
$user->role->equals(RoleEnum::marketing);
|
|
|
|
|
}
|
2023-10-06 15:00:42 +02:00
|
|
|
}
|