|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\TechTips; |
|
4
|
|
|
|
|
5
|
|
|
use App\Events\NewTipCommentEvent; |
|
6
|
|
|
use App\Http\Controllers\Controller; |
|
7
|
|
|
use App\Http\Requests\TechTips\CommentRequest; |
|
8
|
|
|
use App\Models\TechTipComment; |
|
9
|
|
|
use Illuminate\Http\Request; |
|
10
|
|
|
use Illuminate\Support\Facades\Log; |
|
11
|
|
|
|
|
12
|
|
|
class CommentController extends Controller |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Display a listing of the resource. |
|
16
|
|
|
* |
|
17
|
|
|
* @return \Illuminate\Http\Response |
|
18
|
|
|
*/ |
|
19
|
|
|
public function index() |
|
20
|
|
|
{ |
|
21
|
|
|
// |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Show the form for creating a new resource. |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Illuminate\Http\Response |
|
28
|
|
|
*/ |
|
29
|
|
|
public function create() |
|
30
|
|
|
{ |
|
31
|
|
|
// |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Store a new comment on a Tech Tip |
|
36
|
|
|
*/ |
|
37
|
|
|
public function store(CommentRequest $request) |
|
38
|
|
|
{ |
|
39
|
|
|
TechTipComment::create([ |
|
40
|
|
|
'tip_id' => $request->tip_id, |
|
41
|
|
|
'user_id' => $request->user()->user_id, |
|
42
|
|
|
'comment' => $request->comment, |
|
43
|
|
|
]); |
|
44
|
|
|
|
|
45
|
|
|
// event(new EventsTechTipComment($request->tip_id, $request->comment)); |
|
46
|
|
|
event(new NewTipCommentEvent($request->tip_id, $request->comment, $request->user()->full_name)); |
|
47
|
|
|
|
|
48
|
|
|
Log::info('New comment has been created on Tech Tip ID '.$request->tip_id.' by '.$request->user()->username); |
|
49
|
|
|
return back()->with(['message' => 'Comment submitted', 'type' => 'success']); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Display the specified resource. |
|
54
|
|
|
* |
|
55
|
|
|
* @param int $id |
|
56
|
|
|
* @return \Illuminate\Http\Response |
|
57
|
|
|
*/ |
|
58
|
|
|
public function show($id) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
// |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Show the form for editing the specified resource. |
|
65
|
|
|
* |
|
66
|
|
|
* @param int $id |
|
67
|
|
|
* @return \Illuminate\Http\Response |
|
68
|
|
|
*/ |
|
69
|
|
|
public function edit($id) |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
// |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Update the specified resource in storage. |
|
76
|
|
|
* |
|
77
|
|
|
* @param \Illuminate\Http\Request $request |
|
78
|
|
|
* @param int $id |
|
79
|
|
|
* @return \Illuminate\Http\Response |
|
80
|
|
|
*/ |
|
81
|
|
|
public function update(Request $request, $id) |
|
|
|
|
|
|
82
|
|
|
{ |
|
83
|
|
|
// |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Remove the specified resource from storage. |
|
88
|
|
|
* |
|
89
|
|
|
* @param int $id |
|
90
|
|
|
* @return \Illuminate\Http\Response |
|
91
|
|
|
*/ |
|
92
|
|
|
public function destroy($id) |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
|
|
// |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.