CasellaJr
4 months ago

404 | Not found

Posted 4 months ago by CasellaJr

Hi everyone. I have a problem with "404 |Not found". The route exists, but I still have the problem. My file web.php:

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/p/create', '[email protected]');
Route::get('/p/{post}', '[email protected]'); 
Route::post('/p', '[email protected]');

Route::get('/profile/{user}', '[email protected]')->name('profile.show');
Route::get('/profile/{user}/edit', '[email protected]')->name('profile.edit'); //this shows the form of edit profile
Route::patch('/profile/{user}', '[email protected]')->name('profile.update'); //this will actually do the process of updating our profile

My functions edit and update, in ProfilesController.php:

public function edit(User $user){
        return view('profiles.edit', compact('user'));
    }

public function update(User $user){ //some validation
        $data =request()->validate([
            'title' => 'required',
            'description' => 'required',
            'url' => 'url', //require the http://
            'image' => '',
        ]);

        auth()->user()->profile->update($data); //auth() is a protection. Without this, an external user, for example in incognite, can edit the profile
    }

With the command:

php artisan route:list

I can see that the route really exists.

How can I solve?

Please sign in or create an account to participate in this conversation.