Passed
Push — dev6 ( c88035...50a53d )
by Ron
17:16
created

CommentController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 8
c 1
b 0
f 0
dl 0
loc 82
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 13 1
A index() 0 2 1
A create() 0 2 1
A destroy() 0 2 1
A show() 0 2 1
A edit() 0 2 1
A update() 0 2 1
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)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

58
    public function show(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

69
    public function edit(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

81
    public function update(Request $request, /** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

81
    public function update(/** @scrutinizer ignore-unused */ Request $request, $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

92
    public function destroy(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
93
    {
94
        //
95
    }
96
}
97