avatar); } public function getLastActiveATAttribute($value) { return $this->getLastActivedAt($value); } /** * @param $path */ public function setAvatarAttribute($path) { if (!starts_with($path, 'http')) { $path = config('app.url') . "/storage/app/public/avatar/{$path}"; } $this->attributes['avatar'] = $path; } /** * @param $model * @return bool */ public function isAuthorOf($model) { return $this->id == $model->user_id; } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function replies() { return $this->hasMany(Reply::class, 'user_id'); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function topics() { return $this->hasMany(Topic::class); } /** * @param $value */ public function setPasswordAttribute($value) { if (!isset($value[59])) { $value = bcrypt($value); } $this->attributes['password'] = $value; } /** * @param $instance */ public function notify($instance) { if ($this->id == Auth::id()) { return; } $this->increment('notification_count'); $this->laravelNotify($instance); } public function markAsRead() { $this->notification_count = 0; $this->save(); $this->unreadNotifications->markAsRead(); } }