forked from REBELinBLUE/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplate.php
100 lines (88 loc) · 2.04 KB
/
Template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace REBELinBLUE\Deployer;
use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;
use REBELinBLUE\Deployer\Traits\ProjectRelations;
use REBELinBLUE\Deployer\View\Presenters\CommandPresenter;
/**
* Model for templates.
*/
class Template extends Model implements HasPresenter
{
use ProjectRelations;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
/**
* Fields to show in the JSON presentation.
*
* @var array
*/
protected $visible = ['id', 'name', 'command_count', 'file_count', 'config_count', 'variable_count'];
/**
* Additional attributes to include in the JSON representation.
*
* @var array
*/
protected $appends = ['command_count', 'file_count', 'config_count', 'variable_count'];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
];
/**
* Define a accessor for the count of projects.
*
* @return int
*/
public function getCommandCountAttribute()
{
return $this->commands
->count();
}
/**
* Define a accessor for the count of persistent files.
*
* @return int
*/
public function getFileCountAttribute()
{
return $this->sharedFiles
->count();
}
/**
* Define a accessor for the count of config files.
*
* @return int
*/
public function getConfigCountAttribute()
{
return $this->configFiles
->count();
}
/**
* Define a accessor for the count of env variables.
*
* @return int
*/
public function getVariableCountAttribute()
{
return $this->variables
->count();
}
/**
* Gets the view presenter.
*
* @return string
*/
public function getPresenterClass()
{
return CommandPresenter::class;
}
}