I need to change the value of columns from "0" to "1" after click on the Validate Button in my Application.
The column is saved as "0" by default.
I need to find the right ID of the invoice and update this value. So I tried this code, but my update function is not working.
In view: (Each button got the ID of my invoice)
<form action="{{route('Invoice.update', ['id' => $in->id])}}" method="post">
{{method_field('patch')}}
{{csrf_field()}}
<input type="hidden" name="catid" id="catid" >
<button type="submit" data-catid="{{$in->id}}"></button>
</form>
Controller: (Find the Id invoice from value f input)
public function update(Request $request, $id)
{
$invoice = Invoice::findOrFail($request->catid);
$invoice->validate = 1;
$invoice->save();
return back();
}
route:
Route::resource('Invoice','ValidateController');
Errors:
- No query results for model [App\Invoice].
Edited Thanks...