doulan9287 2017-10-30 09:01
浏览 53
已采纳

controller @ store未定义laravel中的错误

I installed laravelcollective and am trying to run the following code

{!! Form::open(['action' => 'ProductController@store','method' => 'POST']) !!}
    <div class="form-group">
        {{Form::label('title','Title')}}
        {{Form::text('title',['class' => 'form-control', 'placeholder' => 'Title'])}}
    </div>
{!! Form::close() !!}

I get this error

App\Http\Controllers\ProductController@store not defined. (View: /Applications/MAMP/htdocs/lsapp/resources/views/product/create.blade.php)

When I run php artisan route:list I see:

    |        | GET|HEAD  | api/user               |                  | Closure              | api,auth:api |
|        | POST      | events                 | events.store     | App\Http\Controllers\eventcontroller@store              | web          |
|        | GET|HEAD  | events                 | events.index     | App\Http\Controllers\eventcontroller@index              | web          |
|        | GET|HEAD  | events/create          | events.create    | App\Http\Controllers\eventcontroller@create              | web          |
|        | PUT|PATCH | events/{event}         | events.update    | App\Http\Controllers\eventcontroller@update              | web          |
|        | GET|HEAD  | events/{event}         | events.show      | App\Http\Controllers\eventcontroller@show              | web          |
|        | DELETE    | events/{event}         | events.destroy   | App\Http\Controllers\eventcontroller@destroy              | web          |
|        | GET|HEAD  | events/{event}/edit    | events.edit      | App\Http\Controllers\eventcontroller@edit              | web          |
|        | GET|HEAD  | home                   | home             | App\Http\Controllers\HomeController@index              | web,auth     |
|        | POST      | login                  |                  | App\Http\Controllers\Auth\LoginController@login              | web,guest    |
|        | GET|HEAD  | login                  | login            | App\Http\Controllers\Auth\LoginController@showLoginForm              | web,guest    |
|        | POST      | logout                 | logout           | App\Http\Controllers\Auth\LoginController@logout              | web          |
|        | POST      | password/email         | password.email   | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web,guest    |
|        | GET|HEAD  | password/reset         | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest    |
|        | POST      | password/reset         |                  | App\Http\Controllers\Auth\ResetPasswordController@reset              | web,guest    |
|        | GET|HEAD  | password/reset/{token} | password.reset   | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web,guest    |
|        | POST      | register               |                  | App\Http\Controllers\Auth\RegisterController@register              | web,guest    |
|        | GET|HEAD  | register               | register         | App\Http\Controllers\Auth\RegisterController@showRegistra
  • 写回答

3条回答 默认 最新

  • douwen3127 2017-10-30 16:37
    关注

    for the best practice and to have maintained code I wish to follow my advice :

    1) go to routes/web.php and add name to your ProductController@store method like this :

    Route::post('','ProductController@store')->name('products.store');
    

    2) go to you create.blade.php file and change it like this :

    {!! Form::open(array( 'route'=>'products.store')) !!} 
        <div class="form-group">    
        {{Form::label('title','Title')}}  
        {{Form::text('title',['class' => 'form-control', 'placeholder' => 'Title'])}} 
        </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里