Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maaz's avatar
Level 2

missing required parameters.

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)
0 likes
3 replies
ajithlal's avatar

where you are calling category.update route?. You have a typo in your form action url.

<form role="form" action="{{route('category.updated',$productCategory->id)}}" method="post">

it should be

<form role="form" action="{{route('category.update',$productCategory->id)}}" method="post">
maaz's avatar
Level 2

still it was not working i find that error too.. btw thanks.

ajithlal's avatar

@maaz the error is not from the from. can you show full edit.blade.php file?

Please or to participate in this conversation.