GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( d22bab...41c46a )
by Nikhil
15:46 queued 08:03
created

ModelController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.1865

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 16
ccs 6
cts 14
cp 0.4286
rs 9.4285
cc 1
eloc 13
nc 1
nop 1
crap 1.1865
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Events\ModelWasCreated;
6
use App\Events\ModelWasDeleted;
7
use App\Model;
8
use File;
9
use Illuminate\Http\Request;
10
11
class ModelController extends Controller
12
{
13
    /**
14
     * ModelController constructor.
15
     */
16 8
    public function __construct()
17
    {
18 8
        $this->middleware('auth');
19 8
    }
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return \Illuminate\Http\Response
25
     */
26 1
    public function index()
27
    {
28 1
        return view('models.index');
29
    }
30
31
    /**
32
     * Store a newly created resource in storage.
33
     *
34
     * @param  \Illuminate\Http\Request $request
35
     */
36 2
    public function store(Request $request)
37
    {
38 2
        $this->validate($request, [
39 2
            'name'    => 'required|string|max:255',
40 2
            'make_id' => 'required|exists:makes,id',
41 2
            'photo'   => 'required|image',
42 2
        ]);
43
        $photo    = $request->file('photo');
44
        $fileName = sha1(time() . $photo->getClientOriginalName()) . '.' . $photo->getClientOriginalExtension();
45
        $photo->move(config('shop.images.path'), $fileName);
46
        $model = Model::create($request->only([
47
                'name',
48
                'make_id'
49
            ]) + ['photo' => config('shop.images.dir') . $fileName]);
50
        event(new ModelWasCreated($model));
0 ignored issues
show
Unused Code introduced by
The call to ModelWasCreated::__construct() has too many arguments starting with $model.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
51
    }
52
53
    /**
54
     * Remove the specified resource from storage.
55
     *
56
     * @param  int $id
57
     */
58 2
    public function destroy($id)
59
    {
60 2
        $model = Model::findOrFail($id);
61 2
        File::delete(public_path($model->photo));
62 2
        $model->delete();
63 2
        event(new ModelWasDeleted($model));
0 ignored issues
show
Unused Code introduced by
The call to ModelWasDeleted::__construct() has too many arguments starting with $model.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
64 2
    }
65
}
66