Scenario #1
ok, lets just say that a topic can belong to many theme
and that at this point in the process you are wanting to display the topic and show what theme it is in. Since the topic can belong to many themes, you don't know which one to show.
In which case, the url can be like /theme/{theme_id}/topic/{topic_id}
In the theme view where you want to click and go to topic, create a link like
<a href="{{ route('topic',[$theme->id,$topic->id]) }}">{{ $topic->topic_title }}</a>
In the controller, grab the two models by their id's
public function show($theme_id, $topic_id);
{
$theme = Theme::findOrFail($theme_id);
$topic = Topic::findOrFail($topic_id);
return view('topic')->withTheme($theme)->withTopic($topic);
}
Scenario #2
ok, lets just say that a topic can belong to only one theme
At this point you want to show the topic and which theme it belongs
In which case, the url can be like /topic/{topic_id}
In the theme view where you want to click and go to topic, create a link like
<a href="{{ route('topic',$topic->id) }}">{{ $topic->topic_title }}</a>
In the controller, grab the topic model by its id, and eager load the theme
public function show($topic_id);
{
$topic = Topic::with('theme')->findOrFail($topic_id);
return view('topic')->withTheme($topic->theme)->withTopic($topic);
}
On that final line, notice the $topic->theme - this is so that you have a $theme variable and don't have to use $topic everywhere you want theme information in the view
In both scenarios, you now have $theme and $topic available to display