显示当天的文章Laravel

时间:2018-02-14 18:19:15

标签: laravel eloquent

我在db上创建了“文章”,其字段为“created_at”=“2018-02-11 01:22:03”。我怎样才能获得当天的链接?

$articles = Article::where('status', 1)->take(5)->get();
return view("site.view", compact("articles"));

1 个答案:

答案 0 :(得分:2)

$articles = Article::whereDate('created_at', today())->where('status', 1)->take(5)->get();