Passed
Push — master ( 6ed66a...c3d33f )
by Jonas
06:02
created

RootAncestor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Staudenmeir\LaravelAdjacencyList\Eloquent\Relations;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\HasOne;
8
9
class RootAncestor extends HasOne
10
{
11
    use IsAncestorRelation {
12
        __construct as __constructParent;
13
        addConstraints as addConstraintsParent;
14
    }
15
    /**
16
     * Create a new root ancestor relationship instance.
17
     *
18
     * @param \Illuminate\Database\Eloquent\Builder $query
19
     * @param \Illuminate\Database\Eloquent\Model $parent
20
     * @param string $foreignKey
21
     * @param string $localKey
22
     * @return void
23
     */
24
    public function __construct(Builder $query, Model $parent, $foreignKey, $localKey)
25
    {
26
        $this->__constructParent($query, $parent, $foreignKey, $localKey, false);
27
    }
28
29
    /**
30
     * Set the base constraints on the relation query.
31
     *
32
     * @return void
33
     */
34
    public function addConstraints()
35
    {
36
        $this->addConstraintsParent();
37
38
        $this->query->isRoot();
39
    }
40
}
41