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');
i recomenod better rephrase the question and the title, and taking advantage of where that comes from
id_master
– Bulfaitelo
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.');
– Raphael Godoi
Great. This is a problem and I solved it now. As for Route, thank you. But there is. Thank you brothers for your time!
– Emilio Dami Silva
{{method_field('patch')}}
I think just remove this, why is changing the verb? If not put the route and improve the question.– novic
That’s right, I’ll set the course. Blz brother.
– Emilio Dami Silva