操作未定义laravel/php控制器
我在laravel项目中遇到控制器操作问题,我不知道为什么,因为一切似乎都很好 以下是我关于错误部分的路线:操作未定义laravel/php控制器,php,laravel,controller,routes,action,Php,Laravel,Controller,Routes,Action,我在laravel项目中遇到控制器操作问题,我不知道为什么,因为一切似乎都很好 以下是我关于错误部分的路线: Route::get('/reminds','RemindController@index'); Route::get('/reminds','RemindController@create'); 以下是在rementcontroller.php文件中定义的创建和索引方法: public function index() { $reminds = Remind::al
Route::get('/reminds','RemindController@index');
Route::get('/reminds','RemindController@create');
以下是在rementcontroller.php文件中定义的创建和索引方法:
public function index()
{
$reminds = Remind::all();
return View::make('remind.index', compact('reminds'));
}
public function create()
{
try {
$listyears = RemindController::generate_list(date('Y')-100, 101);
$listmonths = RemindController::generate_list(1, 12);
$listdays = RemindController::generate_list(1, 31);
return View::make('remind.create', compact('listyears', 'listmonths', 'listdays'));
} catch (Exception $e){
App:abort(404);
}
}
在create.blade.php(提醒视图)中,我有一个调用有问题索引的命令:
<div class="panel-heading">
<h2>create reminder</h2>
</div>
<div class="panel-body">
{!! Form::open(['action'=> 'RemindController@index', 'class' => 'form']) !!}
但是我清楚地定义了它。我不明白。谢谢您使用相同的url和方法定义了两条路由
Route::get('/reminds','RemindController@index');
Route::get('/reminds','RemindController@create');
重命名其中一个
Route::get('/reminds','RemindController@index');
Route::get('/reminds/create','RemindController@create');
您使用相同的url和相同的方法定义了两个路由
Route::get('/reminds','RemindController@index');
Route::get('/reminds','RemindController@create');
重命名其中一个
Route::get('/reminds','RemindController@index');
Route::get('/reminds/create','RemindController@create');
路由::获取(“/提醒”,”RemindController@index');
路由::获取(“/提醒”,”RemindController@create');
这是同一条路线,所以从技术上讲,这一部分你已经有问题了。尝试更改HTTP协议或重命名路由
Route::get('reminds','RemindController@index');
Route::post('reminds','RemindController@create');
或
也可以省略路线上的第一个斜杠,这样做没有用
---更新*
而不是使用静态呼叫路由
你可以用这样的东西
$router->group(function(){
$this->get('/',['as' => "homepage" , 'use' => "MainController@homepage"] );
$this->group(['prefix' => "dashboard",'as' => "dashboard"],function(){
$this->get('/',['as' => "index",'use' => "DashboardController@index"]);
});
});
路由::获取(“/提醒”,”RemindController@index');
路由::获取(“/提醒”,”RemindController@create');
这是同一条路线,所以从技术上讲,这一部分你已经有问题了。尝试更改HTTP协议或重命名路由
Route::get('reminds','RemindController@index');
Route::post('reminds','RemindController@create');
或
也可以省略路线上的第一个斜杠,这样做没有用
---更新*
而不是使用静态呼叫路由
你可以用这样的东西
$router->group(function(){
$this->get('/',['as' => "homepage" , 'use' => "MainController@homepage"] );
$this->group(['prefix' => "dashboard",'as' => "dashboard"],function(){
$this->get('/',['as' => "index",'use' => "DashboardController@index"]);
});
});
您已经为相同的http谓词编写了相同的路由url 只要根据您的需要重新命名即可。
为了简单起见,建议为路由添加name()。您已经为相同的http谓词编写了相同的路由url 只要根据您的需要重新命名即可。
为了简单起见,建议添加name()。为了防止这对某人有所帮助,我也出现了同样的错误,但我的问题是我在定义路由时意外使用了
route::resource()
,而不是route::get()
。我假设这与Route::post()
的情况相同,只是为了防止这对某人有所帮助,我犯了同样的错误,但我的问题是我在定义路由时意外使用了Route::resource()
,而不是Route::get()
。我假设这与Route::post()
Route::get(“/empts/create”,”的情况相同RemindController@create'); 可能应该是Route::post(“/emptures”,”RemindController@create');@jcorry他的create方法只是用来显示数据的,所以在我看来get没问题。post更适合于storemethodroute::get(“/employs/create”,”RemindController@create'); 可能应该是Route::post(“/emptures”,”RemindController@create');@jcorry他的create方法只是用来显示数据的,所以在我看来没问题。post更多的是针对store方法的,谢谢!解释得很好。这是从拉威尔5号开始做新的吗?事实上不是。不再建议对全局变量进行静态调用。您可以使用route()->、session()->、cache()->等,而不是通过route:()、session:、cache::等调用它,我将更新我的答案以使其更清晰谢谢!解释得很好。这是从拉威尔5号开始做新的吗?事实上不是。不再建议对全局变量进行静态调用。您可以使用route()->、session()->、cache()->等,而不是通过route:()、session:、cache::等调用它,我将更新我的答案以使其更清楚