Laravel 5.4 用户配置文件 NotFoundHttpException

Laravel 5.4 User Profile NotFoundHttpException

我正在创建一个允许他修改他的信息的用户配置文件,这里是代码

class ProfilesController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        return view('content.profil');
    }

    public function editProfile($id)
    {   
        $user = User::find($id);
        return view('content.edit', ['user' => $user]);
    }

    public function updateProfile(Request $request, $id)
    {
        $user = User::find($id);

        $user->name = $request->input('name');
        $user->nom = $request->input('nom');
        $user->prenom = $request->input('prenom');
        $user->adresse = $request->input('adresse');
        $user->code_postal = $request->input('code_postal');
        $user->ville = $request->input('ville');
        $user->pays = $request->input('pays');
        $user->num_tele = $request->input('num_tele');

        $user->save();
        return redirect('/profil');

    }
}

Web.php

Route::group(['middleware' =>'auth'], function(){
  Route::get('/profil', 'ProfilesController@index')->name('profil');
  Route::get('/content', 'ProfilesController@editProfile')->name('profil.edit');
  Route::post('/content', 'ProfilesController@updateProfile')->name('profil.update');
});

视图文件夹树看起来像

view/content/profil.blade.php
view/content/edit.blade.php

问题是路由已定义,但它向我显示此错误消息:

(1/1) NotFoundHttpException

我不知道问题到底出在哪里 提前致谢

以同样的方式将您的 profil.edit 路线更正为 /content/{id}/editProfileprofil.update

如果你有命名路由尝试使用 route() 助手而不是 url() 来生成 url,它更干净更通用。

与您的路线 (web.php) 和您想要的相比,这就是您的 web.php 文件应该的样子

  Route::group(['middleware' =>'auth'], function(){
         Route::get('/profil', 'ProfilesController@index')->name('profil');
         Route::get('/content/{id}/editProfile', 'ProfilesController@editProfile')->name('profil.edit');
         Route::post('/content/{id}', 'ProfilesController@updateProfile')->name('profil.update');
});