1class User extends Model {
2 use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
3
4 public function cards() {
5 return $this->hasManyDeep(Card::class, [Subject::class, Deck::class]);
6 }
7}
8
1//App\User;
2
3public function cards()
4{
5 Card::whereHas('decks', function($q){
6 return $q->whereHas('subjects', function($q){
7 return $q->where('user_id', $this->id);
8 });
9 });
10}
11