douyi1341 2017-05-30 18:41
浏览 245

Laravel路由抛出NotFoundHttpException

I'm looking for some help. I've searched on other topics, and saw what is the problem approximatively, but didn't succeed to fix it on my code. Now the question is: I have NotFoundHttpException when i try to submit an update on my code.

Here is the Controller and my function update

<?php

namespace App\Http\Controllers;

use Request;
use App\Http\Requests;
use App\T_collaborateurs_table;

class testing extends Controller
{
    public function index()
    {
        $user = T_collaborateurs_table::all();
        return view ("read", compact("user"));
    }
    public function create()
    {
        return view("create");
    }

    public function store(Request $Request)
    {
        T_collaborateurs_table::create(Request::all());

        return redirect("index");
    }

    public function show($id)
    {
        $user=T_collaborateurs_table::find($id);
        return view("show", compact("user"));
    }

    public function edit($id)
    {
        $user=T_collaborateurs_table::find($id);
        return view("update", compact("user"));
    }

    public function update(Request $Request, $id)
    {
        $user = T_collaborateurs_table::find($id);
        $user->update(Request::all());

        return redirect("index");
    }
}

Now the routes

Route::get("create", "testing@create");
Route::post("store", "testing@store");
Route::get("index", "testing@index");
Route::get("show/{id}", "testing@show");
Route::get("edit/{id}", "testing@edit");
Route::patch("update/{id}", "testing@update");

And now the view update.blade.php

<body>
    {{Form::model($user, ['method'=>'patch', 'action'=>['testing@update',$user->id]])}}

    {{Form::label('Id_TCa', 'ID')}}
    {{Form::text('Id_TCa')}}
    {{Form::label('Collaborateur_TCa', 'collab')}}
    {{Form::text('Collaborateur_TCa')}}
    {{Form::label('Responsable_TCa', 'resp')}}
    {{Form::text('Responsable_TCa')}}

    {{Form::submit("update")}}
    {{Form::close()}}
</body>

Here the route:list

I'm sorry if my words are not very understable... Thank you all for your time.

  • 写回答

3条回答 默认 最新

  • douao2019 2017-05-30 23:25
    关注

    Try using on function update:

    return redirect()->route('index');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?