for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sfneal\Helpers\Time\Traits;
use Sfneal\Helpers\Time\TimeConverter;
/**
* A time value attributes to an Eloquent Model.
*
* @property $total_duration
* @property $total_seconds
*/
trait Duration
{
* Retrieve the total duration in minutes with decimals.
* @return float
abstract public function getTotalDurationAttribute();
* Retrieve total duration converted to hours.
* @return string
public function getTotalHoursAttribute()
return (new TimeConverter())->setMinutes($this->total_duration)->getHours();
}
* Retrieve total duration converted to minutes without decimals.
* @return false|float
public function getTotalMinutesAttribute()
return floor($this->total_duration);
* Retrieve total duration converted to seconds.
* @return float|int
public function getTotalSecondsAttribute()
return $this->total_duration * 60;
* Retrieve total seconds converted to 'hours:minutes:seconds' datetime.
public function getTotalTimeAttribute()
return (new TimeConverter())->setSeconds($this->total_seconds)->getHours();