Try something like
public function getDurationAttribute()
{
return $this->end->diffForHumans($this->start);
}
Then just access it using :
$model->duration;
Beware of some edge cases (this code will fail if end is null).
Also you can use the Carbon documentation about dates comparaisons and differences:
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community