Reputation: 55
last night i tried and check several times tried to seek "konsuman" in my route, model, controller, database, and views. but i found nothing. the correct value is "konsumen" but after run in browser show error
ErrorException (E_ERROR)
Missing required parameters for [Route: konsumen.update]
[URI: konsumen/{konsuman}]. (View: D:\xampp\htdocs
\skh\resources\views\konsumen\edit.blade.php).
i check in several times to make sure its "konsumen" not "konsuman" but laravel show error like above.
is there any mistaken in my code or maybe another erorr. enclosed my complete work.
here is the link of my complete code in route, model, controller, database and view. thank you for the attention given
Upvotes: 0
Views: 1614
Reputation: 5582
You are missing one thing. In your controller, you are accepting the $konsumen
model object. But you didn't define how your $konsumen
will convert to the model object. Because from URL you are getting an id.
To solve this you need to do some settings in your RouteServiceProvide
class. Below is the code you need to add in your provider:-
public function boot()
{
Route::model('konsumen', \App\Konsumen::class);
parent::boot();
}
After this, your code will work.
Upvotes: 0
Reputation: 1952
This is one drawback of using resource
in laravel route. It does create all the CURD routes, but it has its own standards that you need to follow.
So when you have created
Route::resource('konsumen', 'KonsumenController');
This in turn generated the routes that you can see in your screenshot.
Take a look at the update route
, it expects a parameter.
So whereever you are using konsumen.update
route you also need to pass a parameter konsuman
.
So it would be like this
route('konsumen.update', ['konsuman' => <someValue>])
Just like @PhucLam said
Upvotes: 0
Reputation: 370
You forgot add param to route('konsumen.update')
.
It should be route('konsumen.update', ['konsuman' => $id])
$id
is the id of konsumen record you're editing.
Upvotes: 1
Reputation: 164
Try replacing the form action tag value in
edit.blade.php
to <form action="{{ '/konsumen/'. $konsumen->kde_konsumen) }} " method="POST">
Upvotes: 0
Reputation: 474
You forgot to write required in kde_konsumen
$request->validate([
'kde_konsumen',
'nma_konsumen' => 'required',
'alm_konsumen' => 'required',
'tlp_konsumen' => 'required',
]);
to
$request->validate([
'kde_konsumen' => 'required',
'nma_konsumen' => 'required',
'alm_konsumen' => 'required',
'tlp_konsumen' => 'required',
]);
Upvotes: 0