89 lines
1.7 KiB
PHP
89 lines
1.7 KiB
PHP
<?php
|
|
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\AdminStatus;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
/**
|
|
* Class Admin
|
|
*
|
|
* @property int $id
|
|
* @property string $full_name
|
|
* @property string $username
|
|
* @property string $email
|
|
* @property string $mobile
|
|
* @property string $password
|
|
* @property int $status
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
*
|
|
* @package App\Models
|
|
*/
|
|
class Admin extends Authenticatable
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'admins';
|
|
|
|
public static $snakeAttributes = false;
|
|
|
|
protected $casts = [
|
|
'status' => 'int',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'full_name',
|
|
'username',
|
|
'email',
|
|
'mobile',
|
|
'password',
|
|
'status',
|
|
];
|
|
|
|
public function permissions()
|
|
{
|
|
return $this->belongsToMany(
|
|
Permission::class,
|
|
'admin_permission',
|
|
'admin_id',
|
|
'permission_id'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* بررسی دسترسی مدیر به ماژول مدیریت کاربران
|
|
*/
|
|
public function canManageUsers(string $action): bool
|
|
{
|
|
return $this->status == 1;
|
|
}
|
|
|
|
public function canManageTravelTypes(string $action): bool
|
|
{
|
|
return $this->status == 1;
|
|
}
|
|
|
|
public function canManageFlights(string $action): bool
|
|
{
|
|
return $this->status == 1;
|
|
}
|
|
|
|
public function canManageTours(string $action): bool
|
|
{
|
|
return $this->status == 1;
|
|
}
|
|
}
|