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

artisticre's avatar

Route Not Showing on Route:List

I am trying to use this route I made but its not registering on php artisan route:list so when I click the link, it says not found. What am I doing wrong?

Route::get('/category/edit/{id}',[CategoryController::class,'EditCat'])->name('edit.category');

Controller

  public function EditCat($id){
      $categories = Category::find($id);
      return view('admin.category.edit',compact('categories'));

        
    }

Link

<a href="{{ url('/category/edit/'.$cat->id) }}" class="btn btn-primary btn-sm float-left">Edit</a>
0 likes
7 replies
MichalOravec's avatar
Level 75

Use named route.

<a href="{{ route('edit.category', ['id' => $cat->id]) }}" class="btn btn-primary btn-sm float-left">Edit</a>

And run

php artisan route:clear

Because you have cached routes and never do that during development.

1 like
artisticre's avatar

I added the following and I get syntax error, unexpected 'id' (T_STRING), expecting ')'

      <a href="{{ route('edit.category, ['id' => $cat->id]) }}" class="btn btn-primary btn-sm float-left">Edit</a>


but if I add I get Route [store.category] not defined.

      <a href="{{ route('edit.category', ['id' => $cat->id]) }}" class="btn btn-primary btn-sm float-left">Edit</a>

tykus's avatar

route('edit.category, ['id' => $cat->id]) is missing a closing ' after category

MichalOravec's avatar

It sometimes happens when I write a code here.

You supposed to be able to figure it out by yourself.

warpig's avatar

Route::get('/category/edit/{id}',

I think the convention is to use it like this:

'/category/{id}/edit'

but maybe you can declare URI however you want, im not sure, maybe try it in that order.

elminson's avatar

I have try this

php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:clear
php artisan event:clear

but you also need to run this

php artisan optimize:clear

Please or to participate in this conversation.