Hassan Elshazly Eida
Hassan Elshazly Eida

Reputation: 849

Replacing URL ID by title on Laravel ** Without using model ** [Slug]

I want to pass a link with ID and show the title of this id in URL [SEO] without using any Model

<a href="/salons/{{ $salon->id()}}" >Book Appointment</a>

Upvotes: 0

Views: 435

Answers (1)

Maulik Shah
Maulik Shah

Reputation: 1050

You can do one thing, Pass id from here and in controller get data from id, title but when page render you can use javascript replace state.

You can replace your id with title once page render.

It will just replace your url. And also you have to put there condition that if title is integer when click on link (In which you passed id) you have to fetch data based on id for that you can use laravel when method for conditional data fetch. And if slug passed (When page rendered and title is replaced with id) you have to fetch it based on title-slug.

Javascript Replace State(URL)

Laravel Conditional Query

Hope it helps :)

Upvotes: 1

Related Questions