BelongsTo   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addEagerConstraints() 0 4 1
A addConstraints() 0 7 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: admin
5
 * Date: 03.03.2018
6
 * Time: 15:37
7
 */
8
9
namespace sonrac\Arango\Eloquent\Reletations;
10
11
use Illuminate\Database\Eloquent\Relations\BelongsTo as BaseBelongsTo;
12
13
class BelongsTo extends BaseBelongsTo
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function addEagerConstraints(array $models)
19
    {
20
        $this->query->whereIn($this->ownerKey, $this->getEagerModelKeys($models));
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function addConstraints()
27
    {
28
        if (static::$constraints) {
29
            $this->query->where($this->ownerKey, '==', $this->child->{$this->foreignKey});
30
            $this->query->whereNotNull($this->ownerKey);
31
        }
32
    }
33
}
34