|
5 | 5 | use Illuminate\Database\Eloquent\Builder; |
6 | 6 | use Illuminate\Support\Collection; |
7 | 7 | use Illuminate\Support\Facades\DB; |
8 | | -use MongoDB\Laravel\Eloquent\Model; |
| 8 | +use MongoDB\Laravel\Tests\Eloquent\Models\EloquentWithAggregateModel1; |
| 9 | +use MongoDB\Laravel\Tests\Eloquent\Models\EloquentWithAggregateModel2; |
| 10 | +use MongoDB\Laravel\Tests\Eloquent\Models\EloquentWithAggregateModel3; |
| 11 | +use MongoDB\Laravel\Tests\Eloquent\Models\EloquentWithAggregateModel4; |
9 | 12 | use MongoDB\Laravel\Tests\TestCase; |
10 | 13 |
|
11 | 14 | use function count; |
@@ -260,95 +263,3 @@ private static function assertSameResults(array $expected, Collection $collectio |
260 | 263 | self::assertSame($expected, $actual); |
261 | 264 | } |
262 | 265 | } |
263 | | - |
264 | | -class EloquentWithAggregateModel1 extends Model |
265 | | -{ |
266 | | - protected $connection = 'mongodb'; |
267 | | - public $table = 'one'; |
268 | | - public $timestamps = false; |
269 | | - protected $guarded = []; |
270 | | - |
271 | | - public function twos() |
272 | | - { |
273 | | - return $this->hasMany(EloquentWithAggregateModel2::class, 'one_id'); |
274 | | - } |
275 | | - |
276 | | - public function fours() |
277 | | - { |
278 | | - return $this->hasMany(EloquentWithAggregateModel4::class, 'one_id'); |
279 | | - } |
280 | | - |
281 | | - public function allFours() |
282 | | - { |
283 | | - return $this->fours()->withoutGlobalScopes(); |
284 | | - } |
285 | | - |
286 | | - public function embeddeds() |
287 | | - { |
288 | | - return $this->embedsMany(EloquentWithAggregateEmbeddedModel::class); |
289 | | - } |
290 | | -} |
291 | | - |
292 | | -class EloquentWithAggregateModel2 extends Model |
293 | | -{ |
294 | | - protected $connection = 'mongodb'; |
295 | | - public $table = 'two'; |
296 | | - public $timestamps = false; |
297 | | - protected $guarded = []; |
298 | | - protected $withCount = ['threes']; |
299 | | - |
300 | | - protected static function boot() |
301 | | - { |
302 | | - parent::boot(); |
303 | | - |
304 | | - static::addGlobalScope('app', function ($builder) { |
305 | | - $builder->latest(); |
306 | | - }); |
307 | | - } |
308 | | - |
309 | | - public function threes() |
310 | | - { |
311 | | - return $this->hasMany(EloquentWithAggregateModel3::class, 'two_id'); |
312 | | - } |
313 | | -} |
314 | | - |
315 | | -class EloquentWithAggregateModel3 extends Model |
316 | | -{ |
317 | | - protected $connection = 'mongodb'; |
318 | | - public $table = 'three'; |
319 | | - public $timestamps = false; |
320 | | - protected $guarded = []; |
321 | | - |
322 | | - protected static function boot() |
323 | | - { |
324 | | - parent::boot(); |
325 | | - |
326 | | - static::addGlobalScope('app', function ($builder) { |
327 | | - $builder->where('id', '>', 0); |
328 | | - }); |
329 | | - } |
330 | | -} |
331 | | - |
332 | | -class EloquentWithAggregateModel4 extends Model |
333 | | -{ |
334 | | - protected $connection = 'mongodb'; |
335 | | - public $table = 'four'; |
336 | | - public $timestamps = false; |
337 | | - protected $guarded = []; |
338 | | - |
339 | | - protected static function boot() |
340 | | - { |
341 | | - parent::boot(); |
342 | | - |
343 | | - static::addGlobalScope('app', function ($builder) { |
344 | | - $builder->where('id', '>', 1); |
345 | | - }); |
346 | | - } |
347 | | -} |
348 | | - |
349 | | -class EloquentWithAggregateEmbeddedModel extends Model |
350 | | -{ |
351 | | - protected $connection = 'mongodb'; |
352 | | - public $timestamps = false; |
353 | | - protected $guarded = []; |
354 | | -} |
0 commit comments