*/ protected $fillable = [ 'username', 'name', 'password', 'position', 'status', 'avatar' ]; /** * The attributes that should be hidden for serialization. * @var array */ protected $hidden = [ 'password', 'remember_token', 'locale', 'deleted_at', 'updated_at' ]; /** * The attributes that should be cast. * @var array */ 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'); } }