-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathScreenVersion.php
More file actions
86 lines (73 loc) · 1.88 KB
/
ScreenVersion.php
File metadata and controls
86 lines (73 loc) · 1.88 KB
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
<?php
namespace ProcessMaker\Models;
use Illuminate\Database\Eloquent\Builder;
use ProcessMaker\Contracts\PrometheusMetricInterface;
use ProcessMaker\Contracts\ScreenInterface;
use ProcessMaker\Events\TranslationChanged;
use ProcessMaker\Traits\HasCategories;
use ProcessMaker\Traits\HasScreenFields;
class ScreenVersion extends ProcessMakerModel implements ScreenInterface, PrometheusMetricInterface
{
use HasCategories;
use HasScreenFields;
const categoryClass = ScreenCategory::class;
protected $connection = 'processmaker';
/**
* Attributes that are not mass assignable.
*
* @var array
*/
protected $guarded = [
'id',
'updated_at',
];
protected $casts = [
'config' => 'array',
'computed' => 'array',
'watchers' => 'array',
'translations' => 'array',
];
/**
* Boot the model and its events
*/
public static function boot()
{
parent::boot();
}
/**
* Set multiple|single categories to the screen
*
* @param string $value
*/
public function setScreenCategoryIdAttribute($value)
{
return $this->setMultipleCategories($value, 'screen_category_id');
}
/**
* Get the associated screen
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function parent()
{
return $this->belongsTo(Screen::class, 'screen_id', 'id');
}
/**
* Scope to only return draft versions.
*/
public function scopeDraft(Builder $query)
{
return $query->where('draft', true);
}
/**
* Scope to only return published versions.
*/
public function scopePublished(Builder $query)
{
return $query->where('draft', false);
}
public function getPrometheusMetricLabel(): string
{
return 'screen.' . $this->screen_id;
}
}