I have those two tables: apps and categories, they are in a M:M relationship, I have the apps_categories table in place and the BelongsToMany() relations in their models, they work fine.
Now, in a form I'm displaying all the records in apps, but I want to filter based on category_id, so I have a $categories array where I store the filters.
My problem is solved using the DB facade doing like:
$apps = DB::table('apps')
->join('apps_categories', 'apps.id', '=', 'app_id')
->whereIn('category_id', $categories)
->select('apps.*')
->get();
So, I was wondering if there's a better way, using only the ORM. Thing is I have another table with a M:M relationship to apps, and I'm supposing using the ORM would be a better way to handle both relationships