I want to edit a form when click on edit button, i don't know what is the problem with my code I think it looks oky but it is not working and also i am not getting any data from database,
controller:
public function edit(ProductCategory $productCategory)
{
// dd($productCategory);
return view('categories.edit', compact('productCategory'));
}
view:
<tbody>
@foreach ($categories as $cat)
<tr>
<td>{{$cat->id}}</td>
<td class="category-name">{{$cat->name}}</td>
<td>
//edit button
<a href="{{route('category.edit',$cat->id)}}">
<i class="fa fa-edit"></i>
</a>
</td>
<td>
<a href="{{route('category.destroy',$cat->id)}}"
onclick="return confirm('Are you sure you want to delete')" class="fa fa-trash-alt"></a>
</td>
</tr>
@endforeach
edit form
<form role="form" action="{{route('category.updated',$productCategory->id)}}" method="post">
@method('PATCH')
@csrf
<div class="card-body">
<div class="form-group">
<label for="category">Category Title</label>
<input type="text" class="form-control" value="{{$productCategory->name}}" name="category"
id="category" placeholder="Category Title">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Update</button>
<a href="" class="btn btn-warning ml-2">Back</a>
</div>
</div>
</form>
routes:
GET|HEAD | dashboard/category | category.index | App\Http\Controllers\ProductCategoryController@index | web |
| | POST | dashboard/category | category.store | App\Http\Controllers\ProductCategoryController@store | web |
| | GET|HEAD | dashboard/category/create | category.create | App\Http\Controllers\ProductCategoryController@create | web |
| | GET|HEAD | dashboard/category/{category} | category.show | App\Http\Controllers\ProductCategoryController@show | web |
| | PUT|PATCH | dashboard/category/{category} | category.update | App\Http\Controllers\ProductCategoryController@update | web |
| | DELETE | dashboard/category/{category} | category.destroy | App\Http\Controllers\ProductCategoryController@destroy | web |
| | GET|HEAD | dashboard/category/{category}/edit | category.edit | App\Http\Controllers\ProductCategoryController@edit | web
Error i got
Missing required parameters for [Route: category.update] [URI: dashboard/category/{category}]. (View: C:\xampp\htdocs\PointOfSale\resources\views\categories\edit.blade.php)