Skip to content

Commit 6d11574

Browse files
authored
Update model for contact #30
1 parent 2edb370 commit 6d11574

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Models/Contact.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class Contact extends BaseModel
2626
use SoftDeletes;
2727

2828
protected $casts = [
29-
'emailed_at' => 'datetime',
30-
'requested_date' => 'date',
3129
'fields' => 'array',
3230
];
3331

@@ -37,7 +35,9 @@ protected static function boot()
3735

3836
static::creating(function ($contact) {
3937
Assert::lazy()
38+
->that($contact->form_type)->notEmpty('A contact must have a form type.')
4039
->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.')
4141
->verifyNow();
4242
$contact->generateReferenceNumber();
4343
});
@@ -80,6 +80,11 @@ public function getContactStatusHistory(): Collection
8080
{
8181
return $this->getStatusHistory(ContactStatus::statusType());
8282
}
83+
84+
public function location()
85+
{
86+
return $this->belongsTo(app('location'));
87+
}
8388

8489
public function email()
8590
{
@@ -91,21 +96,16 @@ public function phone()
9196
return $this->hasOne(app('phone'));
9297
}
9398

94-
public function response()
99+
public function responses()
95100
{
96-
return $this->hasOne(ContactResponse::class);
101+
return $this->hasMany(ContactResponse::class);
97102
}
98103

99104
public function user()
100105
{
101106
return $this->belongsTo(app('user'));
102107
}
103108

104-
public function location()
105-
{
106-
return $this->belongsTo(app('location'));
107-
}
108-
109109
public function notes()
110110
{
111111
return $this->morphMany(app('note'), 'noteable');

0 commit comments

Comments
 (0)