1voten
1路由
Route::get('/logout', 'Auth\LoginController@logout’);//我看住的点是 auth 下的控制器
2Carbon
日期操作
日期操作可以通过 add (增加)或 sub (减去)跟上要增加或减去的单位来完成。例如,你想给一个日期增加指定的天数,你可以使用 addDays 方法。此外还提供了一个 modify 方法,参数格式为 + 或 - 跟上值及单位。所以,如果你想给当前日期增加一年,你可以传递 +1 year:
- echo Carbon::now()->addDays(25); //2016-11-09 14:00:01
- echo Carbon::now()->addWeeks(3); //2016-11-05 14:00:01
- echo Carbon::now()->addHours(25); //2016-10-16 15:00:01
- echo Carbon::now()->subHours(2); //2016-10-15 12:00:01
- echo Carbon::now()->addHours(2)->addMinutes(12); //2016-10-15 16:12:01
- echo Carbon::now()->modify('+15 days'); //2016-10-30 14:00:01
- echo Carbon::now()->modify('-2 days');
3展现一层一层的
protected function guestHome(Request $request)
{
$submissions = (new Submission())->newQuery();
$submissions->whereIn(
'category_id', $this->getDefaultCategories()
);
$submissions->where('nsfw', false);
if ($request->sort == 'new') {
$submissions->orderBy('created_at', 'desc');
} elseif ($request->sort == 'rising') {
$submissions->where('created_at', '>=', Carbon::now()->subHour())
->orderBy('rate', 'desc');
} else {
$submissions->orderBy('rate', 'desc');
}
$submissions->groupBy('url');
return $submissions->simplePaginate(10);
}