Passed
Push — dev5a ( 915c64...c2cba2 )
by Ron
07:58
created

TipCommentsController::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
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