So i want to convert my duration data from database to be viewed on my view page. I tried made some function on my controller that should convert it.
public function humanTime()
{
$seconds = DB::table('test_executions as e')
->select('e.duration');
$time = CarbonInterval::seconds($seconds)->cascade()->forHumans();
dd($time);
}
And on my view page i want to show it and currently i have this.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TestExecution extends Model
{
/**
* Get the user's first name.
*
* @param string $value
* @return string
*/
public function getFormattedDurationAttribute()
{
return CarbonInterval::seconds($this->duration)->cascade()->forHumans()
}
}