|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Model; |
|
4
|
|
|
|
|
5
|
|
|
use App\Model\Deployment; |
|
6
|
|
|
use App\Model\Finder\EventFinder; |
|
7
|
|
|
use Respect\Validation\Validator; |
|
8
|
|
|
use Ronanchilvers\Orm\Model; |
|
9
|
|
|
use Ronanchilvers\Orm\Traits\HasValidationTrait; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Model representing a deployment event |
|
13
|
|
|
* |
|
14
|
|
|
* @property int id |
|
15
|
|
|
* @property null|\App\Model\Deployment deployment |
|
16
|
|
|
* @property string type |
|
17
|
|
|
* @property string header |
|
18
|
|
|
* @property string detail |
|
19
|
|
|
* @property null|\Carbon\Carbon created |
|
20
|
|
|
* @property null|\Carbon\Carbon updated |
|
21
|
|
|
* @author Ronan Chilvers <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class Event extends Model |
|
24
|
|
|
{ |
|
25
|
|
|
use HasValidationTrait; |
|
26
|
|
|
|
|
27
|
|
|
static protected $finder = EventFinder::class; |
|
28
|
|
|
static protected $columnPrefix = 'event'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Boot the model |
|
32
|
|
|
* |
|
33
|
|
|
* @author Ronan Chilvers <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function boot() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->addType('model', 'deployment', [ |
|
38
|
|
|
'class' => Deployment::class |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @author Ronan Chilvers <[email protected]> |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function setupValidation() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->registerRules([ |
|
48
|
|
|
'deployment' => Validator::notEmpty()->intVal()->min(1), |
|
49
|
|
|
'type' => Validator::notEmpty(), |
|
50
|
|
|
'header' => Validator::notEmpty(), |
|
51
|
|
|
]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Relationship with project |
|
56
|
|
|
* |
|
57
|
|
|
* @return \App\Model\Deployment |
|
58
|
|
|
* @author Ronan Chilvers <[email protected]> |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function relateDeployment() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->belongsTo( |
|
63
|
|
|
Deployment::class |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|