hapzfl's avatar

Web page link to a a different web page

I am a bloody beginner when it comes to Laravel and although I managed to create individual links from a number of article titles to their respective details I am totally lost when trying to create individual links for any of these articles to pages that need to know about the article id:

Main page with article1 (id_a1) -> detail_page (id_detp1) for article1 (id_a1) using id_a1 (that works)

                        article1 (id_a1) -> diff_page (id_diffp1) but associated only with article1 (id_a1)    (needs help)
                        -----------------
                        article2 (id_a2) -> detail_page (id_detp2) for article2 (id_a2) using id_a2       (that works)

                        article2 (id_a2) -> diff_page (id_diffp1) but associated only with article2 (id_a2)     (needs help)

I.e. each main article has 2 links: one to edit/delete the article, and the other to a page that shows a number of different but related articles. Any help is very much appreciated.

0 likes
4 replies
jlrdw's avatar

That is basic crud and Jeffrey covers the basics in his free video series.

Snapey's avatar

Sorry, can't really follow your question.

Why not post some actual code?

Say you had an article controller, and it has a show method that needs an article number. You could name this route article.show and then in the view, create link like


<a href="{{ route('article.show',$article) }}">$article->title</a>

So we created a link, using the name of the article. The route helper creates the href attribute using the name of the route. Passing the article into the route helper, Laravel will get the key for the article and include it in the route.

hapzfl's avatar

Thanks for your reply. I am not surprised that you could not follow my question. I struggled with it when I wrote it.

Your example is what I used to stay within the boundaries of the article. But I need to link to a page outside of the "article". That's why I am struggling. I cannot provide actual code because code to address my problem is what I am looking for.

How do I get the article id into a route that has nothing to do with the article other than that I need to have the article id available in the other route so I can use it there.

jlrdw's avatar

Related articles:

I had to read post several times.

You need a search term to find related articles. So pass along the topic "buzz" word.

Like if that row is about golfing .... Then golf would be key word.

There are probably a hundred or more ways to do that, but only you know your code structure.

Please or to participate in this conversation.