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

christopher's avatar

Quick Question how to handle id`s in the url

For example:

A User has many companies and each companies has many events.

If i edit one of my companies the url would be ../company/1/edit

Ok so far so good .. now i added a event to this company. The url would be ../compmany/1/event/create

Now the "tricky" part if i want to edit this event the url would be:

../company/1/event/1/edit

But this of course does not work because i cant give two ID`s to the routes.php

Should i go for a slug ? Or the better question: How are you guys handle this ?

0 likes
6 replies
RachidLaasri's avatar

It doesn't matter what company the event belongs to, why not make the url event/1/edit ? without "/compmany/1/"

bestmomo's avatar

I suppose you use nested resources so you get ../company/1/event/1/edit in routes. You can exclude this route to simplify url as said @RachidLaasri.

bashy's avatar

Have one resource for events and one resource for companies. When you edit the event, you can always display the company it's attached to in the form/page.

pmall's avatar

You are doing it fine with the two ids in the url. It is always useful to have the parent id in the url.

Route::get('companies/{company_id}/events/{event_id}/edit', ...);
public function edit($category_id, $event_id)
{
  // your edit action
}

Please or to participate in this conversation.