我刚开始接触Laravel 4,试图找出为什么会出现一个错误提示说方法 [show] 不存在。 我没有一个名为“show”的方法,我只能想象这是一个内部的Laravel方法,但我不知道如何影响它或是什么可能导致了这个问题。如果您有任何想法或者帮助,将不胜感激,因为我已经被困在这里两天了,也无法发现我的错误所在。
视图:
视图:
<li><a href="{{ URL::route('account-sign-in') }}">Sign in</a></li>
路由:
/*Sign In (GET)*/
Route::get('/account/sign-in', array(
'as' => 'account-sign-in',
'uses' => 'AccountController@getSignIn'
));
账户控制器:
class AccountController extends BaseController {
public function getSignIn(){
return View::make('user.signIn');
}
public function postSignIn(){
$validator = Validator::make(Input::all(), array( 'email' => 'required|email', 'password' => 'required' ) );
if($validator->fails()){ /*Redirect to the sign in page*/
return Redirect::route('account-sign-in') ->withErrors($validator) ->withInput();
}
else { /*Attempt user sign in*/
$remember = (Input::has('remember')) ? true : false;
$auth = Auth::attempt(array( 'email' => Input::get('email'), 'password' => Input::get('password'), 'active' => 1 ), $remember);
if($auth){
/*Redirect to the intended page*/ return Redirect::intended('/');
}
else {
return Redirect::route('account-sign-in')->with('global', 'Email/password wrong, or account not activated.');
}
}
return Redirect::route('account-sign-in') ->with('global', 'There was a problem signing you in.');
}
}