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 ( 96a04d...9dca68 )
by Nikhil
07:36
created

ModelController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Model;
6
use File;
7
use Illuminate\Http\Request;
8
9
class ModelController extends Controller
10
{
11
    /**
12
     * ModelController constructor.
13
     */
14
    public function __construct()
15
    {
16
        $this->middleware('auth');
17
    }
18
19
    /**
20
     * Display a listing of the resource.
21
     *
22
     * @return \Illuminate\Http\Response
23
     */
24
    public function index()
25
    {
26
        return view('models.index');
27
    }
28
29
    /**
30
     * Store a newly created resource in storage.
31
     *
32
     * @param  \Illuminate\Http\Request $request
33
     */
34
    public function store(Request $request)
35
    {
36
        $this->validate($request, [
37
            'name'    => 'required|string|max:255',
38
            'make_id' => 'required|exists:makes,id',
39
            'photo'   => 'required|image',
40
        ]);
41
        $photo    = $request->file('photo');
42
        $fileName = sha1(time() . $photo->getClientOriginalName()) . '.' . $photo->getClientOriginalExtension();
43
        $photo->move(config('shop.images.path'), $fileName);
44
        Model::create($request->only(['name', 'make_id']) + ['photo' => config('shop.images.dir') . $fileName]);
45
    }
46
47
    /**
48
     * Remove the specified resource from storage.
49
     *
50
     * @param  int $id
51
     */
52
    public function destroy($id)
53
    {
54
        $model = Model::findOrFail($id);
55
        File::delete(public_path($model->photo));
56
        $model->delete();
57
    }
58
}
59