*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'role', 'statushtml', 'profilehtml', 'status_updated_at', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'status_updated_at' => 'datetime', 'role' => 'integer' ]; } public function roles() { return $this->belongsToMany(Role::class); } public function writings() { return $this->hasMany(Writing::class); } public function links(){ return $this->hasMany(Link::class); } public function isAdmin(): bool { return $this->role == 0; } public function getStorageQuota(){ $roles = $this->roles()->get(); $quota = 0; foreach ($roles as $r){ if ($r->storage_quota > $quota){ $quota = $r->storage_quota; } } return $quota; } public function getStorageUsed(){ } public function files(){ return $this->hasMany(File::class); } }