1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\TechTips; |
4
|
|
|
|
5
|
|
|
use App\Domains\TechTips\GetTipComments; |
6
|
|
|
use App\Domains\TechTips\SetTipComments; |
7
|
|
|
use App\Http\Controllers\Controller; |
8
|
|
|
use App\Http\Requests\TechTips\NewCommentrequest; |
9
|
|
|
use Illuminate\Http\Request; |
10
|
|
|
use Illuminate\Support\Facades\Auth; |
11
|
|
|
use Illuminate\Support\Facades\Log; |
12
|
|
|
|
13
|
|
|
class TipCommentsController extends Controller |
14
|
|
|
{ |
15
|
|
|
// Store a new Tech Tip Comment |
16
|
2 |
|
public function store(NewCommentrequest $request) |
17
|
|
|
{ |
18
|
2 |
|
(new SetTipComments)->createTipComment($request, Auth::user()); |
19
|
2 |
|
Log::info('User '.Auth::user()->full_name.' comment on Tech Tip ID '.$request->tip_id.'. Details - ', ['comment' => $request->comment]); |
20
|
2 |
|
return response()->json(['success' => true]); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// Show comments for a Tech Tip |
24
|
2 |
|
public function show($id) |
25
|
|
|
{ |
26
|
2 |
|
return (new GetTipComments)->execute($id); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Show the form for editing the specified resource. |
31
|
|
|
* |
32
|
|
|
* @param int $id |
33
|
|
|
* @return \Illuminate\Http\Response |
34
|
|
|
*/ |
35
|
|
|
// public function edit($id) |
36
|
|
|
// { |
37
|
|
|
// // |
38
|
|
|
// } |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Update the specified resource in storage. |
42
|
|
|
* |
43
|
|
|
* @param \Illuminate\Http\Request $request |
44
|
|
|
* @param int $id |
45
|
|
|
* @return \Illuminate\Http\Response |
46
|
|
|
*/ |
47
|
|
|
// public function update(Request $request, $id) |
48
|
|
|
// { |
49
|
|
|
// // |
50
|
|
|
// } |
51
|
|
|
|
52
|
|
|
// Delete a Tip Comment |
53
|
2 |
|
public function destroy($id) |
54
|
|
|
{ |
55
|
2 |
|
(new SetTipComments)->deleteComment($id); |
56
|
2 |
|
Log::info('User '.Auth::user()->full_name.' deleted Tech Tip Comment ID '.$id); |
57
|
2 |
|
return response()->json(['success' => true]); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|