EagerLoad::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Orkhanahmadov\EloquentRepository\Repository\Eloquent\Criteria;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Database\Eloquent\Builder;
7
use Orkhanahmadov\EloquentRepository\Repository\Criteria\Criterion;
8
9
class EagerLoad implements Criterion
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $relations;
15
16
    /**
17
     * EagerLoad constructor.
18
     *
19
     * @param mixed ...$relations
20
     */
21
    public function __construct(...$relations)
22
    {
23
        $this->relations = Arr::flatten($relations);
24
    }
25
26
    /**
27
     * @param Builder|mixed $model
28
     *
29
     * @return Builder|mixed
30
     */
31
    public function apply($model)
32
    {
33
        return $model->with($this->relations);
34
    }
35
}
36