pickab00
134
21
Laravel

How to show post using another column than ID

Posted 11 months ago by pickab00

I have a table called Post and i want to show the different single posts using the show method. But i want to use my post_id instead of id.

The thing is i am using id for updating my posts. but i want to use post_id to show the posts. when i try:

      <a href={{route('post.show', $post->post_id)}}>{{$post->name}}</a>

it gives me 404. But when i use $post->id it works. Does it has to do with id being the primary key? how can i achieve this?i want to update the posts using id but show the posts using post_id column.

thanks

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.