Rainieren

I got it working, Thanks. I figured it out! Thank you very much!

Rainieren

@Snapey There is one small problem now. The url is switched up now. Its shows the topic of ffeeney which is correct. but the URL is theme/19/topics/1 instead of theme/1/topics/19. What is causing this?

Snapey
Snapey
4 months ago (647,435 XP)

check that this

Route::get('/theme/{theme_id}/topics/{topic_id}', '[email protected]')->name('showtopic');`

theme_id and topic_id are spelled the same as here;

<a href="{{ route('showtopic', ['theme_id'=>$theme->id,'topic_id' => $topic->id ]) }}"

and in the same order

Rainieren

@Snapey Now it shows the correct URL (theme/1/topics/19). but not the correct topic. Now it shows the topic with theme_id 9 and topic_id 1. Instead of the topic with theme_id 1 and topic_id 19. The link looks like this now. As you said. And it works and makes sense! {{ route('showtopic', ['theme_id'=>$theme->id, 'topic_id' => $topic->id]) }}

And my show method looks like this.

public function show($topic_id)
    {

        $topic = Topic::with('theme')->findOrFail($topic_id);

        return view('topics.topic')->withTopic($topic)->withTheme($topic->theme);

    }

I think there is something messed up between the 2 and it is something I can't see otherwise I could've fixed it myself.

Snapey
Snapey
4 months ago (647,435 XP)

it's this public function show($topic_id)

You have switched back to using one parameter again.

OMG

Rainieren

@Snapey You told me to.... What am I supposed to put there then.

This is literally what you told me to do. in your post with the Scenarios.

Snapey
Snapey
4 months ago (647,435 XP)

Yes, but then you still went on about needing the theme in the URL

So I wrote new instructions.

Look, its easy, If you want the theme id AND the topic id then you have TWO ids and you must use TWO IDs everywhere. Two in the route definition, two in the href, two in the show method

If you just want ONE id then this must be the topic ID and you must use ONE everywhere. One in the route definition, one in the href, one in the show method

Your choice. Topic id only or theme id + topic id

Rainieren

@Snapey Okay, i understand it now. Sorry for asking you so much but I was just not thinking straight. Thanks for your help! It works and I got it now! thanks!

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