|bool */ protected $guarded = ['id']; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = [ 'completed_at', 'archived_at', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'completed' => 'boolean', 'archived' => 'boolean', ]; /** * Eager load with every task. */ protected $with = [ 'account', 'contact', ]; /** * Get the account record associated with the task. * * @return BelongsTo */ public function account() { return $this->belongsTo(Account::class); } /** * Get the contact record associated with the task. * * @return BelongsTo */ public function contact() { return $this->belongsTo(Contact::class); } /** * Limit tasks to completed ones. * * @param Builder $query * @return Builder */ public function scopeCompleted(Builder $query) { return $query->where('completed', true); } /** * Limit tasks to in-progress ones. * * @param Builder $query * @return Builder */ public function scopeInProgress(Builder $query) { return $query->where('completed', false); } }