Is there any "Laravel-ish" way to capture the earliest and latest dates from multiple date fields in several laravel tables?
table for model1:
fielda| fieldb| date1
table2 for model2:
fieldc| fieldd| date1| date2
I couldn't find any elegant way to do it. My current approach is something like:
$model1_dates = Model1::select(\DB::raw('MIN(date1) as min_date'), \DB::raw('MAX(date1) as max_date'))->get(); $model2_dates = Model2::select(\DB::raw('MIN(date2) as min_date'), \DB::raw('MAX(date2) as max_date'))->get(); $model2_dates2 = Model2::select(\DB::raw('MIN(date2) as min_date'), \DB::raw('MAX(date1) as max_date'))->get();
afterwards, I will compare the results and get the minimum and maximum of those...
What approaches would be better?
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Jy80Yh
via IFTTT
Aucun commentaire:
Enregistrer un commentaire