【发布时间】:2020-08-25 08:04:20
【问题描述】:
您好,我想检查用户电子邮件是否仅在控制器的一个功能中验证,我不想在中间件或这样的路由中设置检查:
public function __construct()
{
$this->middleware('verified');
}
因为来宾可以访问控制器,所以控制器中只有一个功能(创建)需要验证电子邮件并登录用户我该怎么做,谢谢
public function create()
{
// checking if authenticated but need to check if email verified also
if (Auth::check()) {
// Get the currently authenticated user...
$user = Auth::user();
// get the list of states
$states = State::orderBy('name', 'asc')->get();
// get all cities by state_id
$state_id = '1';
$cities = City::where('state_id', $state_id)->orderBy('name', 'asc')->get();
return view('pages.create_product', ['user' => $user, 'states' => $states, 'cities' => $cities]);
} else {
return redirect()->route('login');
}
}
【问题讨论】:
标签: laravel