I have the following models in laravel:
TheJobs - id - description - created_at - deleted_at - updated_at TheSeries - id - title - description - created_at - deleted_at - updated_at TheMovies - id - title - description - created_at - deleted_at - updated_at mSeriesJobs - seriesID - jobID mMoviesJobs - movieID - jobID
Here are the ratios for TheJobs
:
public function TheSeries() { return $this->belongsToMany('App\Models\TheSeries', 'mSeriesJobs', 'jobID', 'seriesID'); } public function TheMovies() { return $this->belongsToMany('App\Models\TheMovies', 'mMoviesJobs', 'jobID', 'movieID'); }
Here are the ratios for TheSeries
:
public function TheJobs() { return $this->belongsToMany('App\Models\TheJobs', 'mSeriesJobs', 'seriesID', 'jobID'); }
for movies.
I would like to:
- Get all
TheSeries
. - Get all
TheMovies
assignments. - Get all jobs with
TheSeries
or TheMovies
data.
To clarify the question:
I need a simple Eloquent query that selects all TheSeries
that have at least one TheJobs
.
Coder source share