+13
-1
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PurchasingRole;
|
||||
use App\Services\OrganizationAccess;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
@@ -15,7 +16,7 @@ use Illuminate\Support\Carbon;
|
||||
* @property int $id
|
||||
* @property int|null $tenant_id
|
||||
* @property int|null $department_id
|
||||
* @property PurchasingRole $purchasing_role
|
||||
* @property PurchasingRole|null $purchasing_role
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property Carbon|null $email_verified_at
|
||||
@@ -31,6 +32,17 @@ use Illuminate\Support\Carbon;
|
||||
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @param list<PurchasingRole|string> $functions */
|
||||
public function hasFunctions(array $functions): bool
|
||||
{
|
||||
return app(OrganizationAccess::class)->allows($this, $functions);
|
||||
}
|
||||
|
||||
public function departmentScoped(): bool
|
||||
{
|
||||
return app(OrganizationAccess::class)->departmentScoped($this);
|
||||
}
|
||||
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user