BelongsTo::addEagerConstraints()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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