@@ -26,8 +26,6 @@ class Contact extends BaseModel
26
26
use SoftDeletes;
27
27
28
28
protected $ casts = [
29
- 'emailed_at ' => 'datetime ' ,
30
- 'requested_date ' => 'date ' ,
31
29
'fields ' => 'array ' ,
32
30
];
33
31
@@ -37,7 +35,9 @@ protected static function boot()
37
35
38
36
static ::creating (function ($ contact ) {
39
37
Assert::lazy ()
38
+ ->that ($ contact ->form_type )->notEmpty ('A contact must have a form type. ' )
40
39
->that ($ contact ->location_id )->notEmpty ('A contact must be made to a location. ' )
40
+ ->that ($ contact ->email_address_id )->notEmpty ('A contact must supply an email address. ' )
41
41
->verifyNow ();
42
42
$ contact ->generateReferenceNumber ();
43
43
});
@@ -80,6 +80,11 @@ public function getContactStatusHistory(): Collection
80
80
{
81
81
return $ this ->getStatusHistory (ContactStatus::statusType ());
82
82
}
83
+
84
+ public function location ()
85
+ {
86
+ return $ this ->belongsTo (app ('location ' ));
87
+ }
83
88
84
89
public function email ()
85
90
{
@@ -91,21 +96,16 @@ public function phone()
91
96
return $ this ->hasOne (app ('phone ' ));
92
97
}
93
98
94
- public function response ()
99
+ public function responses ()
95
100
{
96
- return $ this ->hasOne (ContactResponse::class);
101
+ return $ this ->hasMany (ContactResponse::class);
97
102
}
98
103
99
104
public function user ()
100
105
{
101
106
return $ this ->belongsTo (app ('user ' ));
102
107
}
103
108
104
- public function location ()
105
- {
106
- return $ this ->belongsTo (app ('location ' ));
107
- }
108
-
109
109
public function notes ()
110
110
{
111
111
return $ this ->morphMany (app ('note ' ), 'noteable ' );
0 commit comments