gpt4 book ai didi

methods - "Method [show] does not exist"是什么意思?

转载 作者:行者123 更新时间:2023-12-03 08:23:45 34 4
gpt4 key购买 nike

我是 Laravel 4 的新手,并试图弄清楚为什么我收到一个错误,说 Method [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'
));

帐户 Controller :
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.');
}
}

最佳答案

What does “Method [show] does not exist” mean?



您的问题中提供的代码没有显示有关 show() 的任何信息方法,反正。根据您的评论,您没有扩展 BaseController但是你所有的 Controller 都应该扩展 BaseController 和 BaseController应该扩展 Controller所以这就是您的 BaseController应该看起来像(默认情况下):
class BaseController extends Controller {

/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
}

您的 Controller 应该像这样扩展它:
class AccountController extends BaseController {

// Define all of your methods
// including show() if you are using it

}

关于methods - "Method [show] does not exist"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22444928/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com