I have 3 tables: companies, games and tests.
- Companies have many games
- Games have many tests
The Game
model has a global scope, which I can confirm is working:
public function apply(Builder $builder, Model $model)
{
$builder->where('type', 'live');
}
Any direct queries I do using the Game
model will only return results where the game type is set to "live".
I am using return $this->hasManyThrough('App\Test', 'App\Games')
in my Company
model to get all tests for a particular company.
However, this is returning results for all games, regardless of their type.
So I am wondering if using hasManyThrough
bypasses the global scope that I've set in the Game
model?
If so, is there any way around this? I want to make sure that all queries I'm doing are filtering out any games that aren't set to "live".
Cheers
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire