停车场管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

65 lines
1.4 KiB

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class AdminUsers extends Model
{
use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
/**
* The attributes that are mass assignable.
* @var array<int, string>
*/
protected $fillable
= [
'username',
'name',
'password',
'position',
'status',
'avatar'
];
/**
* The attributes that should be hidden for serialization.
* @var array<int, string>
*/
protected $hidden
= [
'password',
'remember_token',
'locale',
'deleted_at',
'updated_at'
];
/**
* The attributes that should be cast.
* @var array<string, string>
*/
protected $casts = [];
/**
* @return BelongsToMany
*/
public function roles(): BelongsToMany
{
return $this->belongsToMany(AdminRoles::class, AdminRoleUsers::class, 'user_id', 'role_id');
}
/**
* @param $user_id
* @return mixed
*/
public static function getUsername($user_id): mixed
{
return self::query()->where('id', $user_id)->value('username');
}
}