Passed
Push — dev5 ( 3ab1f5...1f5b4d )
by Ron
06:22
created

TechTipCommentsController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 15
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Http\Controllers\TechTips;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use App\TechTipComments;
8
use Illuminate\Support\Facades\Auth;
9
10
class TechTipCommentsController extends Controller
11
{
12 8
    public function __construct()
13
    {
14 8
        $this->middleware('auth');
15 8
    }
16
    /**
17
     * Store a newly created resource in storage.
18
     *
19
     * @param  \Illuminate\Http\Request  $request
20
     * @return \Illuminate\Http\Response
21
     */
22 2
    public function store(Request $request)
23
    {
24
        //
25 2
        $request->validate([
26 2
            'comment' => 'required',
27
            'tipID' => 'required',
28
        ]);
29
30 2
        TechTipComments::create([
31 2
            'tip_id' => $request->tipID,
32 2
            'user_id' => Auth::user()->user_id,
33 2
            'comment' => $request->comment
34
        ]);
35
36 2
        return response()->json(['success' => true]);
37
    }
38
39
    /**
40
     * Display the specified resource.
41
     *
42
     * @param  int  $id
43
     * @return \Illuminate\Http\Response
44
     */
45 2
    public function show($id)
46
    {
47 2
        return TechTipComments::where('tip_id', $id)->with('User')->get();
48
    }
49
50
    /**
51
     * Show the form for editing the specified resource.
52
     *
53
     * @param  int  $id
54
     * @return \Illuminate\Http\Response
55
     */
56
    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

56
    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...
57
    {
58
        //
59
    }
60
61
    /**
62
     * Update the specified resource in storage.
63
     *
64
     * @param  \Illuminate\Http\Request  $request
65
     * @param  int  $id
66
     * @return \Illuminate\Http\Response
67
     */
68
    public function update(Request $request, $id)
0 ignored issues
show
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

68
    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...
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

68
    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...
69
    {
70
        //
71
    }
72
73
    /**
74
     * Remove the specified resource from storage.
75
     *
76
     * @param  int  $id
77
     * @return \Illuminate\Http\Response
78
     */
79
    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

79
    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...
80
    {
81
        //
82
    }
83
}
84