사용자가 속한 부서에만 액세스 할 수 있도록 경로를 보호하려면 어떻게해야합니까? 내 현재 필터 :필터를 사용하여 laravel의 경로 보호
Route::filter('department', function ($route, $request) { // Check to see if the current user belongs to the department: if (!Request::isMethod('post')) { if($request->segment(2) != "create") { if (!Auth::user()->canAccessDepartment($request->segment(2))) { // The user shouldn't be allowed to access the department! Redirect them return Redirect::to('/')->with('notice', 'Error!');; } } } });
는 그리고이
public function canAccessDepartment($department_id) {
$user = Confide::user();
if ($user->departments()->where('department_id', $department_id)->count() < 1)
{
return false;
}
else{ return true; }
}
특정 부서 도메인/부서/2,하지만 난 도메인/부서 (모든 부서를 나열 것이다) 내가 얻을에 액세스하려고하면 "/"로 리디렉션되는 "error" – SuperManSL
도메인/부서에 액세스하면 컨트롤러에서 index() 함수를 호출 할 것입니다. 거기에있는 코드는 어떻게 생겼습니까? –
만 해당 \t \t 돌아 가기보기 :: make ('department.index'); – SuperManSL