title: Is there a way to make this query without raw part, between realtion models?
body: <p><strong>User Model:</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Database\Eloquent\Collection;
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Illuminate\Notifications\Notifiable;
  use Laravel\Sanctum\HasApiTokens;
  
  class User extends Authenticatable
  {
      use HasApiTokens, HasFactory, Notifiable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var string[]
       */
      protected $fillable = [
          'name',
          'email',
          'password',
      ];
  
      /**
       * The attributes that should be hidden for serialization.
       *
       * @var array
       */
      protected $hidden = [
          'password',
          'remember_token',
      ];
  
      /**
       * The attributes that should be cast.
       *
       * @var array
       */
      protected $casts = [
          'email_verified_at' =&gt; 'datetime',
      ];
  
      public function venues()
      {
          return $this-&gt;hasMany(Venue::class);
      }
  
      public function reviews()
      {
          return $this-&gt;hasMany(Review::class);
      }
  
      public function profile()
      {
          return $this-&gt;hasOne(Profile::class);
      }
  
      public function approvedVenues()
      {
          return $this-&gt;hasMany(Venue::class)-&gt;where('is_approved', '=', 1);
      }
  
      public function unapprovedVenues()
      {
          return $this-&gt;hasMany(Venue::class)-&gt;where('is_approved', false);
      }
  
      public function ownVenuesReviews()
      {
          return $this-&gt;reviews()-&gt;whereIn('user_id', function($query) {
              $query-&gt;select('id')
              -&gt;from('venues')
              -&gt;whereRaw('venues.user_id = users.id');
          })-&gt;get();
      }
  }
  </code></pre>
  <p><strong>Venue Model:</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  
  class Venue extends Model
  {
      use HasFactory;
  
      protected $fillable = [
          'user_id',
          'city_id',
          'category_id',
          'title',
          'address',
          'phone',
          'email',
          'website',
          'facebook',
          'instagram',
          'content_bg',
          'content_en',
          'cover_image',
          'lat',
          'lng'
      ];
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class, 'user_id');
      }
  
      public function category()
      {
          return $this-&gt;belongsTo(Category::class, 'category_id');
      }
  
      public function city()
      {
          return $this-&gt;belongsTo(City::class, 'city_id');
      }
  
      public function features()
      {
          return $this-&gt;belongsToMany(Feature::class, 'venue_feature');
      }
  
      public function images()
      {
          return $this-&gt;hasMany(VenueImage::class);
      }
  
      public function reviews()
      {
          return $this-&gt;hasMany(Review::class);
      }
  }
  </code></pre>
  <p><strong>Review Model:</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  
  class Review extends Model
  {
      use HasFactory;
  
      protected $fillable = ['rating', 'content', 'venue_id', 'user_id'];
  
      public function venue()
      {
          return $this-&gt;belongsTo(Venue::class);
      }
  
      public function images()
      {
          return $this-&gt;hasMany(ReviewImage::class);
      }
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  }
  </code></pre>
  <p>So Users have many Venues, Venues have many reviews.</p>
  <p>I want to get reviews on own Venues for example (If I own venues with id 100, 101 - I want to get all reviews for these two venues)</p>
  <p><strong>Raw query is this:</strong></p>
  <pre><code>SELECT * FROM `reviews` WHERE reviews.venue_id IN (SELECT venues.id FROM venues WHERE venues.user_id = 1)
  </code></pre>
  <p><strong>What I tried in Laravel in User model (doesn't work), I'm also curious if there is a way, without raw part:</strong></p>
  <pre><code>public function ownVenuesReviews()
  {
      return $this-&gt;reviews()-&gt;whereIn('user_id', function($query) {
          $query-&gt;select('id')
          -&gt;from('venues')
          -&gt;whereRaw('venues.user_id = users.id');
      })-&gt;get();
  }
  </code></pre>