相关疑难解决方法(0)

Laravel Carbon,在工作日检索今天的日期?

我使用碳来比较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)

datetime laravel php-carbon laravel-5

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

datetime ×1

laravel ×1

laravel-5 ×1

php-carbon ×1