我使用碳来比较2个日期和今天的日期,但是我在一个名为weekday的数据库中还有另一个字段,其中包含以下值:
'MO''TU''我们'
所以我不仅希望按日期搜索和输出,还要按工作日搜索:
public function show($id)
{
$today = Carbon::now();
$weekday = //whatever carbon or something else has to retrieve today's day
$event = Event::with('businesses')
->where('startdate', '<', $today->format('Y-m-d'))
->where('endate', '>', $today->format('Y-m-d'))
//or where ('weekday') = $weekday?
->get();
return view('events.showEvent', compact('event'));
}
Run Code Online (Sandbox Code Playgroud)