laravel 5.5 通过命令创建 M层和C层 还有验证器
php artisan make:controller Admin\JiancezhanController
php artisan make:model Models\Jiancezhan
php artisan make:request JiancezhanCreateRequest
在laravel中__construct是高于session的,说白了就是还没有开启session,需要使用下面的中间件去判断session是否存在
public function __construct()
{
$this->request = request();
// 验证是否登录
$this->middleware(function ($request, $next) {
if (!\Session::get('id') && static::$need_auth) {
redirect('admin/login/login')->send();exit(); //如果session没有就跳转登录页面
}
return $next($request);
});
}