has many through where pivot code example
Example: Has Many Through Pivot
AudioFiles::whereHas('podcast', function($query) use ($user) { return $query->whereHas('user', function($query) use ($user) { return $query->where('user_id', $user->id) ->where('has_paid', true); });})->orderBy('created_at', 'desc')->get();