Passed
Pull Request — master (#69)
by
unknown
10:33
created

HasManyThroughJson::addConstraints()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
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 8
rs 10
1
<?php
2
3
namespace Staudenmeir\EloquentJsonRelations\Relations;
4
5
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
6
use Illuminate\Contracts\Support\Arrayable;
7
use Illuminate\Database\Eloquent\Builder;
8
use Illuminate\Database\Eloquent\Collection;
9
use Illuminate\Database\Eloquent\Model;
10
use Illuminate\Database\Eloquent\ModelNotFoundException;
11
use Illuminate\Database\Eloquent\Relations\Concerns\InteractsWithDictionary;
12
use Illuminate\Database\Eloquent\SoftDeletes;
13
14
class HasManyThroughJson extends HasManyThrough
15
{
16
    /**
17
     * Set the base constraints on the relation query.
18
     *
19
     * @return void
20
     */
21
    public function addConstraints()
22
    {
23
        
24
        $localValue = $this->farParent[$this->localKey];
25
        $this->performJoin();
26
27
        if (static::$constraints) {
28
            $this->query->whereJsonContains($this->getQualifiedFirstKeyName(), $localValue);
29
        }
30
    }
31
32
   
33
}
34