35 lines
844 B
PHP
35 lines
844 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
use App\Models\InstantWin;
|
|
use App\Models\Prize;
|
|
use App\Models\User;
|
|
use App\Policies\Rules\UserStaticRules;
|
|
|
|
class InstantWinPolicy
|
|
{
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @return boolean
|
|
*/
|
|
public function viewAny(User $authUser): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can generate models.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @return boolean
|
|
*/
|
|
public function generate(User $authUser): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
|
((Prize::getCached()->count() and !InstantWin::count()) ? true : false);
|
|
}
|
|
}
|