Test Failed
Pull Request — master (#4)
by
unknown
11:18
created

BelongsTo   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 22
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
    /**
17
     * @inheritdoc
18
     */
19
    public function addEagerConstraints(array $models)
20
    {
21
        $this->query->whereIn($this->ownerKey, $this->getEagerModelKeys($models));
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function addConstraints()
28
    {
29
        if (static::$constraints) {
30
            $this->query->where($this->ownerKey, '==', $this->child->{$this->foreignKey});
31
            $this->query->whereNotNull($this->ownerKey);
32
        }
33
    }
34
}