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

IsConcatenableDescendantsRelation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getThroughKeyForDeepRelationships() 0 11 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