Completed
Push — master ( a964bf...08af9f )
by David
05:01 queued 18s
created

Page::template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace App\LaravelRestCms\Page;
2
3
use App\LaravelRestCms\BaseModel;
4
use App\LaravelRestCms\Page\PageDetail;
5
use App\LaravelRestCms\Template\Template;
6
7
class Page extends BaseModel {
8
9
	public static $searchCols = ['nav_name', 'url', 'title'];
10
11
	/**
12
	 * The database table used by the model.
13
	 *
14
	 * @var string
15
	 */
16
	protected $table = 'pages';
17
18
	/**
19
	 * The attributes that are mass assignable.
20
	 *
21
	 * @var array
22
	 */
23
	protected $fillable = ['parent_id', 'template_id', 'nav_name', 'url', 'title', 'created_by', 'updated_by'];
24
25
	/**
26
	 * The attributes excluded from the model's JSON form.
27
	 *
28
	 * @var array
29
	 */
30
	protected $hidden = [];
31
32
	/**
33
	 * Rules to validate when creating a model
34
	 * 
35
	* @var array
36
	 */
37
	protected static $createRules = [	
38
		'name' => 'required|unique:templates',
39
		'layout' => 'required',
40
	];
41
42
	/**
43
	 * Indicates if the model should be attributed with created_by and updated_by
44
	 * 
45
	* @var bool
46
	 */
47
	public $attirbution = false;
48
49
	/**
50
	 * Joins the page_detail table
51
	 * 
52
	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
53
	 */
54
	public function detail()
55
    {
56
        return $this->hasMany(PageDetail::class, 'page_id', 'id');
57
    }
58
59
	/**
60
	 * Joins the templates table
61
	 * 
62
	 * @return \Illuminate\Database\Eloquent\Relations\hasOne
63
	 */
64
	public function template()
65
    {
66
        return $this->hasMany(Template::class, 'id', 'template_id');
67
    }
68
69
	/**
70
	 * Joins the pages table
71
	 * 
72
	 * @return \Illuminate\Database\Eloquent\Relations\hasOne
73
	 */
74
	public function parent()
75
    {
76
        return $this->hasMany(Page::class, 'id', 'parent_id');
77
    }
78
79
}
80