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 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口