How do I get the data from a relationship table?
this is the tables' structure:
paradises
id - integer
title - string
travel_interest_id - integer
travel_interests
id - integer
name - string
and this is my code so far
Models/Paradise.php
public function travelInterests()
{
return $this->belongsTo(TravelInterest::class);
}
Models/TravelInterest.php
public function paradises()
{
return $this->hasMany(Paradise::class);
}
in this Controller, I'm getting all the data from the travel_interests table instead of just one record that is associated with the paradise record.
ParadiseController.php
public function show(Paradise $paradise)
{
dd($paradise->travelInterests->get());
}
what am I doing wrong? any help is appreciated..
$paradise->travelInterestslaravel.com/docs/11.x/eloquent-relationships#one-to-many