belongsTo('App\Account'); } public function scopeCompleted(Builder $query) { return $query->where('status', 'completed'); } public function scopeInProgress(Builder $query) { return $query->where('status', 'inprogress'); } public function getTitle() { if (is_null($this->title)) { return null; } return $this->title; } public function getDescription() { if (is_null($this->description)) { return null; } return $this->description; } public function getCreatedAt() { return $this->created_at; } /** * Change the status of the task from in progress to complete, or the other * way around. */ public function toggle() { if ($this->status == 'completed') { $this->status = 'inprogress'; } else { $this->status = 'completed'; } $this->save(); } }