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.
Test Setup Failed
Push — master ( 273301...d40dfb )
by Nikhil
19:35 queued 09:51
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.216

Importance

Changes 5
Bugs 2 Features 2
Metric Value
c 5
b 2
f 2
dl 0
loc 16
ccs 6
cts 15
cp 0.4
rs 9.4285
cc 1
eloc 13
nc 1
nop 1
crap 1.216
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));
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
        event(new ModelWasDeleted($model));
63 2
        $model->delete();
64 2
    }
65
}
66