Passed
Push — master ( 1543af...f8a677 )
by Jonas
04:29 queued 16s
created

getThroughKeyForDeepRelationships()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Traits\Concatenation;
4
5
trait IsConcatenableDescendantsRelation
6
{
7
    use IsConcatenableRelation;
8
9
    /**
10
     * Get the custom through key for an eager load of the relation.
11
     *
12
     * @param string $alias
13
     * @return array
14
     */
15
    public function getThroughKeyForDeepRelationships(string $alias): array
16
    {
17
        $path = $this->related->qualifyColumn(
18
            $this->related->getPathName()
19
        );
20
21
        $parentKey = $this->related->qualifyColumn(
22
            "pivot_" . $this->related->getParentKeyName()
23
        );
24
25
        return ["$path as {$alias}", "$parentKey as {$alias}_pivot_id"];
26
    }
27
}
28