Laravel informs that the page was not found: 404 on the master/test route

Asked

Viewed 292 times

1

How to make this update work? Below page code.

Form_edit.php

<form role="form">
    <div class="box-body">
        <div class="form-group">
            <label>Name</label>
            <input type="text" 
                    class="form-control" 
                    name="name_masters"
                    id="name_masters"
                    placeholder="Enter masters name">
        </div>                
        <div class="form-group">
            <label for="email_masters">Email address</label>
            <input type="email" 
                name="email_masters"
                id="email_masters"
                class="form-control" 
                placeholder="Enter masters email">
        </div>
        <div class="box-footer">
            <button type="submit" class="btn btn-primary">Submit</button>
        </div>
    </div>
</form>

alter.blade.php

<form action="{{route('master.update', 'test')}}" method="post">                 
    {{method_field('patch')}}
    {{csrf_field()}}
    <div class="modal-body">
        <input type="hidden" name="id" id="id" value="">
        @include('Masters.form_edit')
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Save Changes</button>
    </div>
</form>

test.blade.php

{{$user->email}}

Mastercontroller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \App\Master;
use \App\user;
use Gate;

class MasterController extends Controller
{

  public function update(Request $request)
    {

        $master = Master::findOrFail($request->id_master);
        $master->update($request->all());       
        return back();
    }
}
?>

Web.php

Route::post('master', function () { })->name('master.update'); 
  • 1

    i recomenod better rephrase the question and the title, and taking advantage of where that comes from id_master

  • 1

    You are using route in your form action, you have a route in the Routes file with this name, something like Route::post('master/update', Function() ? })->name('master.update.');

  • Great. This is a problem and I solved it now. As for Route, thank you. But there is. Thank you brothers for your time!

  • 1

    {{method_field('patch')}} I think just remove this, why is changing the verb? If not put the route and improve the question.

  • That’s right, I’ll set the course. Blz brother.

1 answer

1


Start by changing your route so you can reach your controller and stop displaying the 404 (Remember that 404 is page not found):

Web.php

Route::post('master', "MasterController@update")->name('master.update'); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.