*/ protected $fillable = [ 'username', 'name', 'email', 'password', 'role', 'is_active', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'is_active' => 'boolean', ]; public function venues(): BelongsToMany { return $this->belongsToMany(Venue::class, 'user_venue')->withTimestamps(); } public function isSuperAdmin(): bool { if ($this->isSuperAdminMemo !== null) { return $this->isSuperAdminMemo; } if ($this->role === 'super_admin') { return $this->isSuperAdminMemo = true; } return $this->isSuperAdminMemo = AdminRole::query() ->where('slug', $this->role) ->where('full_access', true) ->exists(); } }