ParseWithTrait::parseWith()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Modules\Core\Traits\Criteria;
4
5
trait ParseWithTrait
6
{
7
    /** @var \Illuminate\Http\Request $request */
8
    protected $request;
9
    /** @var \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder $model */
10
    protected $model;
11
    /** @var \Prettus\Repository\Contracts\RepositoryInterface $repository */
12
    protected $repository;
13
    protected $search;
14
    protected $searchData;
15
    protected $searchFields;
16
    protected $isFirstField;
17
    protected $modelForceAndWhere;
18
    protected $fieldsSearchable;
19
    protected $fields;
20
    protected $filter;
21
    protected $orderBy;
22
    protected $sortedBy;
23
    protected $with;
24
    protected $searchJoin;
25
    protected $acceptedConditions;
26
    protected $originalFields;
27
    protected $searchClosures;
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
}
39