【发布时间】:2016-09-23 09:13:18
【问题描述】:
对不起,我是 Laravel 的新手。 我想在 Routes.php 中使用 laravel 5.2 中的条件 当用户登录时,我想调用 showExperience 函数,否则重定向到登录
我的 routes.php 代码
Route::get('/profile', function () {
if (Auth::check()) {
$url = action('ProfilesController@showExperience');
return redirect($url);
} else {
return Redirect::to('login');
}
});
这是我的 ProfilesController.php
public function showExperience(){
$data = Experience::all();
return view('profile')->with('experienceData',$data);
}
【问题讨论】:
标签: php laravel-5 laravel-routing