1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Events\ChatMessageSentEvent; |
6
|
|
|
use App\Models\Chat; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
|
9
|
|
|
class ChatController extends Controller |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Display a listing of the resource. |
13
|
|
|
* |
14
|
|
|
* @return \Illuminate\Http\Response |
15
|
|
|
*/ |
16
|
|
|
public function index(Request $request) |
17
|
|
|
{ |
18
|
|
|
$requester = $request->user(); |
19
|
|
|
|
20
|
|
|
return $requester->userChats(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Show the form for creating a new resource. |
25
|
|
|
* |
26
|
|
|
* @return \Illuminate\Http\Response |
27
|
|
|
*/ |
28
|
|
|
public function test() |
29
|
|
|
{ |
30
|
|
|
$event = new ChatMessageSentEvent(); |
31
|
|
|
event($event); |
32
|
|
|
dd('here'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function create() |
36
|
|
|
{ |
37
|
|
|
// |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Store a newly created resource in storage. |
42
|
|
|
* |
43
|
|
|
* @param \Illuminate\Http\Request $request |
44
|
|
|
* @return \Illuminate\Http\Response |
45
|
|
|
*/ |
46
|
|
|
public function store(Request $request) |
47
|
|
|
{ |
48
|
|
|
$event = new ChatMessageSentEvent(); |
49
|
|
|
broadcast($event); |
50
|
|
|
|
51
|
|
|
return $request->all(); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Display the specified resource. |
56
|
|
|
* |
57
|
|
|
* @param \App\Models\Chat $chat |
58
|
|
|
* @return \Illuminate\Http\Response |
59
|
|
|
*/ |
60
|
|
|
public function show(Chat $chat) |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
// |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Show the form for editing the specified resource. |
67
|
|
|
* |
68
|
|
|
* @param \App\Models\Chat $chat |
69
|
|
|
* @return \Illuminate\Http\Response |
70
|
|
|
*/ |
71
|
|
|
public function edit(Chat $chat) |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
// |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Update the specified resource in storage. |
78
|
|
|
* |
79
|
|
|
* @param \Illuminate\Http\Request $request |
80
|
|
|
* @param \App\Models\Chat $chat |
81
|
|
|
* @return \Illuminate\Http\Response |
82
|
|
|
*/ |
83
|
|
|
public function update(Request $request, Chat $chat) |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
// |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Remove the specified resource from storage. |
90
|
|
|
* |
91
|
|
|
* @param \App\Models\Chat $chat |
92
|
|
|
* @return \Illuminate\Http\Response |
93
|
|
|
*/ |
94
|
|
|
public function destroy(Chat $chat) |
|
|
|
|
95
|
|
|
{ |
96
|
|
|
// |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|