@@ -125,13 +125,25 @@ public function test_where_in_subquery()
125125 (new TestModel ())->create (['id ' => $ id , 'name ' => 'A chair ' ]);
126126 (new TestModel ())->create (['id ' => $ id2 , 'name ' => 'A table ' ]);
127127 $ p = TestModel::whereIn ('id ' , function ($ query ) {
128- $ query ->select ('id ' )->from ('test_model ' );
128+ $ query ->select ('id ' )->from ('test_model ' )-> whereNull ( ' location ' ) ;
129129 })->get ();
130130 $ this ->assertEquals (2 , $ p ->count ());
131131 $ this ->assertEquals ($ id , $ p ->first ()->id );
132132 $ this ->assertEquals ($ id2 , $ p ->last ()->id );
133133 }
134134
135+ public function test_where_in_wherein_subquery ()
136+ {
137+ $ id = Uuid::uuid1 ()->toString ();
138+ $ id2 = Uuid::uuid1 ()->toString ();
139+ (new TestModel ())->create (['id ' => $ id , 'name ' => 'A chair ' ]);
140+ (new TestModel ())->create (['id ' => $ id2 , 'name ' => 'A table ' ]);
141+ $ p = TestModel::withWherein ()->get ();
142+ $ this ->assertEquals (2 , $ p ->count ());
143+ $ this ->assertEquals ($ id , $ p ->first ()->id );
144+ $ this ->assertEquals ($ id2 , $ p ->last ()->id );
145+ }
146+
135147 public function test_where_not_in ()
136148 {
137149 $ id = Uuid::uuid1 ()->toString ();
@@ -256,6 +268,14 @@ class TestModel extends Model
256268 'id ' => 'uuid_v1_binary ' ,
257269 'location ' => 'encrypt_string ' ,
258270 ];
271+
272+ public function scopeWithWherein ($ builder )
273+ {
274+ $ builder ->whereIn ('id ' , function ($ subquery ) {
275+ $ subquery ->select ('id ' )->from ('test_model ' )
276+ ->whereNull ('location ' );
277+ });
278+ }
259279}
260280
261281class TimestampedModel extends Model
0 commit comments