This application built in Lavavel 5. I had a table with year of birth value. I query the table using this query:
$tarikh = DB::table('itemregistrations')
->select('itemregistrations.lahir_dd', 'itemregistrations.lahir_mm', 'itemregistrations.lahir_yy')
->get();
I want to calculate the age using carbon and insert into the collection using array map:
$tarikh->map(function ($detail) {$detail->Umur = "{$detail->lahir_yy}->diffInYears(\Carbon::now())";
return $detail;
});
but the formula doesn't work in string "". How to put carbon formula in the array map? thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire