belongsTo(User::class, 'author_id'); } /** * a todo has many mentioned users */ public function mentions() { return $this->belongsToMany(User::class, 'bdotstd_todo_mentions', 'todo_id', 'user_id')->withTimestamps(); } /** * a todo has only one status */ public function status() { return $this->belongsTo(Status::class, 'status_id'); } /** * a todo attaches to a post or other entity */ public function entity() { if ($this->entity_type === 'post') { return Post::find($this->entity_id); } return null; } }