Passed
Push — feature/optimize ( cf938e...7e8046 )
by Fu
03:43
created

ParseWithTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseWith() 0 7 2
1
<?php
2
3
4
namespace Modules\Core\Traits\Criteria;
5
6
trait ParseWithTrait
7
{
8
    /** @var \Illuminate\Http\Request $request */
9
    protected $request;
10
    /** @var \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder $model */
11
    protected $model;
12
    /** @var \Prettus\Repository\Contracts\RepositoryInterface $repository */
13
    protected $repository;
14
    protected $search;
15
    protected $searchData;
16
    protected $searchFields;
17
    protected $isFirstField;
18
    protected $modelForceAndWhere;
19
    protected $fieldsSearchable;
20
    protected $fields;
21
    protected $filter;
22
    protected $orderBy;
23
    protected $sortedBy;
24
    protected $with;
25
    protected $searchJoin;
26
    protected $acceptedConditions;
27
    protected $originalFields;
28
29
    protected function parseWith()
30
    {
31
        $this->with = $this->request->get(config('repository.criteria.params.with', 'with'), null);
32
33
        if ($this->with) {
34
            $this->with = explode(';', $this->with);
35
            $this->model = $this->model->with($this->with);
36
        }
37
    }
38
}