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

HasManyThroughJson   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A addConstraints() 0 8 2
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