SingleType::hasSelfParent()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
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 2
rs 10
cc 2
nc 2
nop 0
1
<?php
2
namespace Prateekkarki\Laragen\Models\Types\Relational;
3
use Prateekkarki\Laragen\Models\Types\RelationalType;
4
5
class SingleType extends RelationalType
6
{
7
    protected $dataType = 'integer';
8
    protected $hasSingleRelation = true;
9
    protected $size = false;
10
    protected $isRelational = false;
11
    protected $formType = 'parent';
12
13
    protected $stubs = [
14
        'modelMethod' => 'common/Models/fragments/hasOne',
15
        'foreignMethod' => 'common/Models/fragments/belongsTo'
16
    ];
17
18
19
    public function getValidationRule() {
20
        return 'exists:'.$this->getRelatedModule().',id';
21
    }
22
23
    public function hasSelfParent() {
24
        return ($this->typeOption == $this->getParentModule() || $this->typeOption == "self");
25
    }
26
27
    public function getColumnKey()
28
    {
29
        return $this->columnName."_id";
30
    }
31
32
}
33