我有收藏promotions,每次促销都有很多exceptions:
foreach ($promotions as $p) {
$t = $p->exceptions()
->where('sunday','on')
->whereDate('start','<=', $c_date)
->whereDate('end','>=', $c_date)
->get()
->sortBy('promotion_id');
echo $t->min('start'). ' from: '.$t->min('start_time') .' ';
echo $t->max('end') . ' to: '.$t->max('end_time').'</br>';
}
因为促销有很多例外,所以我需要知道每个促销的最小日期和最大日期。
上面的代码运行良好,但它使用“开始”作为字符串而不是日期,结果无效。
如何从集合中获取最小日期和最大日期。