Passed
Push — master ( 0ba402...934d75 )
by Bas
05:33
created

MorphMany::addConstraints()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 10
c 2
b 0
f 0
1
<?php
2
3
namespace LaravelFreelancerNL\Aranguent\Eloquent\Relations;
4
5
use Illuminate\Database\Eloquent\Relations\MorphMany as IlluminateMorphMany;
6
7
class MorphMany extends IlluminateMorphMany
8
{
9
    /**
10
     * Set the base constraints on the relation query.
11
     *
12
     * @return void
13
     */
14
    public function addConstraints()
15
    {
16
        if (static::$constraints) {
17
            $this->query->where($this->foreignKey, '=', $this->getParentKey());
18
19
            $this->query->whereNotNull($this->foreignKey);
20
21
            $this->query->where($this->morphType, $this->morphClass);
22
        }
23
    }
24
}
25