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

laravelyv's avatar

Route Not Defined

Hi, I have created a new laravel5.7 project. I have created a new controller named ProductController.php with all product actions functions.

Also created a a route in web.php as Route::resource('products','ProductController');

Created these blades under resources/views/products 1. layout 2. index 3. create 4. edit 5. remove and 6. show.

In the index.blade.php I have these three links for 1. show 2. edit 3. Delete like below.

Show Edit Delete

When I add the last link for Delete I am getting this error - "Route [products.remove] not defined. (View: /opt/lampp/htdocs/test1/resources/views/products/index.blade.php)

I have checked the php artisan route:list and its not showing the remove in the list. I have cleared all cache too.

I am new to Laravel and unable to rectify the issue. Can someone please help me on this? Thanks in advance.

Actually I need to show a confirmation pop up for delete the record. So I created this blade remove.blade.php. When user clicks on this link

Delete

It should open a pop up window (remove.blade.php). My remove.blade.php html is like below.

@extends('products.layout')

@section('content') @csrf @method('PUT')

     <div class="row">
        Are you sure, Do you want to delete this record?
        <div class="col-xs-12 col-sm-12 col-md-12 text-center">
          <button type="submit" class="btn btn-primary">Submit</button>
        </div>
    </div>

</form>

@endsection

When the user submits the button only the record should be deleted. For this functionality I have created the delete as a link in the index.blade.php and am getting the error.

0 likes
6 replies
Sergiu17's avatar
php artisan route:list

in index.php you have

{{ route('products.remove') }} // wrong

but should be

{{ route('products.destroy') }} // correct 

to clear route cache

php artisan route:clear
tykus's avatar

Resource route definitions creates the following:

 GET|HEAD  | products                | products.index   | App\Http\Controllers\ProductController@index   |
| POST      | products                | products.store   | App\Http\Controllers\ProductController@store   |
| GET|HEAD  | products/create         | products.create  | App\Http\Controllers\ProductController@create  |
| GET|HEAD  | products/{product}      | products.show    | App\Http\Controllers\ProductController@show    |
| PUT|PATCH | products/{product}      | products.update  | App\Http\Controllers\ProductController@update  |
| DELETE    | products/{product}      | products.destroy | App\Http\Controllers\ProductController@destroy |
| GET|HEAD  | products/{product}/edit | products.edit    | App\Http\Controllers\ProductController@edit    |

There is no GET route to remove by default; you have to create this if you need it.

Really, all you need is a form that sends a (spoofed DELETE) request to products/{product}:

<form action="{{ route('products.destroy, $product) }} method="POST">
    @csrf
    @method('DELETE')
    <button type="submit">Delete</button>
</form>
laravelyv's avatar

I have updated the post with the issue I am facing. Please check and comment it. Thanks.

tykus's avatar

You will not get a popup window on the current page from a normal GET request; you can conditionally show the popup by intercepting the form submit event using javascript. Implementation will depending on what (if any) javascript framework you are using currently.

Otherwise, you could make an AJAX GET request and append the modal markup to the current view whenever it responds successfully

laravelyv's avatar

Thanks. Ok. I will integrate it with jquery popup.

Please or to participate in this conversation.