'datetime', ]; protected $dates = ['login_at']; public function isAdmin(): bool { return $this->role === 2; } public function memos() : HasMany { return $this->hasMany(Memo::class); } public function toDoLists() : HasMany { return $this->hasMany(ToDoList::class); } public function bookmarks() : HasMany { return $this->hasMany(Bookmark::class); } public function images(): MorphMany { return $this->morphMany(Image::class, 'imageable'); } public function profileImage(): MorphOne { return $this->morphOne(Image::class, 'imageable') ->where('location', 'profile') ->orderBy('id', 'desc') ->withDefault(function ($userImage) { $userImage->path = 'images/default-cover.jpg'; }); } public function coverImage(): MorphOne { return $this->morphOne(Image::class, 'imageable') ->where('location', 'cover') ->orderBy('id', 'desc') ->withDefault(function ($userImage) { $userImage->path = 'images/default-cover.jpg'; }); } public function thumbnailImage(): MorphOne { return $this->morphOne(Image::class, 'imageable') ->orderBy('id', 'desc') ->where('location', 'profile-small') ->withDefault(function ($userImage) { $userImage->path = 'images/default-cover.jpg'; }); } public function events(): HasMany { return $this->hasMany(Event::class); } public function invitedEvent(): BelongsToMany { return $this->belongsToMany(Event::class, 'event_guest', 'user_id', 'event_id') ->withPivot('is_staff', 'validated_at') ->withTimestamps(); } }