forked from musonza/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreConversation.php
More file actions
35 lines (28 loc) · 795 Bytes
/
StoreConversation.php
File metadata and controls
35 lines (28 loc) · 795 Bytes
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
<?php
namespace Musonza\Chat\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreConversation extends FormRequest
{
public function authorized()
{
return true;
}
public function rules()
{
return [
'participants' => 'array',
'participants.*.id' => 'required',
'participants.*.type' => 'required|string',
'data' => 'array',
];
}
public function participants()
{
$participantModels = [];
$participants = $this->input('participants', []);
foreach ($participants as $participant) {
$participantModels[] = app($participant['type'])->find($participant['id']);
}
return $participantModels;
}
}