I've 2 models, CoreChallenge and Challenge. Below are relations between table. 
Now I want only active core_challenges to be displayed. I can do that via global scope in CoreChallenge model. But when I'm getting challenge's it gives me null in relationship when Corechallenge is inactive.
I've done it this way
$challenges = Challenge::with('core_challenge')->whereHas('core_challenge', function($q){
$q->where('status', '=', 'active');
})->get();
I want to do it using global scopes
Global scope on CoreChallenge gives me null, but I want that it's parent (Challenge) should not load even, like in whereHas. Is there any way?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire