Open rvgmartins opened 5 years ago
You can do something like this:
$this['videos'] = WatchLearn\Videos\Models\Video::whereHas('series', function ($query) {
$query->where('slug', '=', $this->param('slug'))->where('published', true);
})->orderBy('created_at', 'asc')->get();
This is an example from my site so I'm basically getting all the videos that belong to a specific series, and getting that series by slug. So my video is a model, and the Series is a different model. And they of course have a relation.
Hope this helps.
Is it possible to search on several models with different rules?
An example with actors and films is it possible to search on both?
I only find search in one model like this:
$items = Models\Movie::where('name', 'like', "%${query}%") ->orWhere('description', 'like', "%${query}%") ->get();