Passed
Branch master (d88b3b)
by Prateek
03:56
created

SingleType::getValidationRule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
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 $relationalType = 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