laravel을 사용하여 작은 프로젝트를 수행하고 있지만 라우팅이 작동하지 않습니다. 아래에서 올바른 방향으로 가리 키십시오. 아래 코드를 게시하십시오.Larevel 4.2 라우팅 매개 변수 % 7Busername % 7D가 작동하지 않습니다.
라우터
Route::get('{username}', array('as' => 'profile', 'uses' => '[email protected]'));
컨트롤러
public function index($username = null) {
$username = Sentry::getUser()->username;
return View::make('home.profile')
->with('title', 'From controller')
->with('username', $username);
}
난 아직도 내가 당신이 원하는 생각하지만 로그인 컨트롤러에 profile
에 리디렉션을 볼 수 없습니다http://social.app/%7Busername%7D
public function postLogin(){
$credentials = Validator::make([
'email' => Input::get('email'),
'password' => Input::get('password')
], [
'email' => 'required|email',
'password' => 'required|alpha_num|between:8,15',
]);
if ($credentials->fails()) {
return Redirect::route('login')
->withInput()
->with('title', 'Welcome to mySite | login')
->withErrors($credentials->getMessageBag());
} else {
try {
$credentials = array(
'email' => Input::has('email') ? Input::get('email') : null,
'password' => Input::has('password') ? Input::get('password') : null,
);
// Log the user in
$user = Sentry::authenticate($credentials, Input::has('remember_me') and Input::get('remember_me') == 'checked');
return View::make('home.profile');
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
return View::make('users.login')
->with('title', 'wrong login')
->with('message', 'Email filed is required');
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
return View::make('users.login')
->with('title', 'something went wrong')
->with('message', 'Password filed is required');
} catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
return View::make('users.login')
->with('title', 'wrong Password')
->with('message', 'The password/login is incorrect.');
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return View::make('users.login')
->with('title', 'Not found')
->with('message', 'Sorry we can't found the user.');
}
}
}
문제는 아마 URL을 생성 할 때입니다. 코드를 보여줄 수 있습니까? – lukasgeiter
로그인에 성공하면 프로필로 사용자를 보냅니다. 그러나 URL은 작동하지 않습니다. 여기에 내 로그인 컨트롤러가 있습니다. –