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 ( 8c82e7...44f2dc )
by Nikhil
09:16
created

app/Http/Controllers/WarehouseController.php (3 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Events\WarehouseWasCreated;
6
use App\Events\WarehouseWasDeleted;
7
use App\Events\WarehouseWasUpdated;
8
use App\Warehouse;
9
use Illuminate\Http\Request;
10
use Illuminate\Http\Response;
11
12
class WarehouseController extends Controller
13
{
14
    /**
15
     * New instance of warehouse controller.
16
     */
17 14
    public function __construct()
18
    {
19 14
        $this->middleware('auth');
20 14
    }
21
22
    /**
23
     * List the warehouses.
24
     * @return Response
25
     */
26 1
    public function index()
27
    {
28 1
        return view('warehouses.index');
29
    }
30
31
    /**
32
     * Create a new warehouse.
33
     *
34
     * @param Request $request
35
     */
36 6
    public function store(Request $request)
37
    {
38 6
        $this->validate($request, [
39 6
            'name'             => 'required|string|max:255',
40
            'racks.*.name'     => 'required|string|max:255',
41
            'racks.*.make_id'  => 'required|exists:makes,id',
42
            'racks.*.capacity' => 'required|integer|min:1',
43
        ]);
44
45 2
        $warehouse = Warehouse::create($request->only(['name']));
46 2
        $racks     = $request->input('racks', []);
47 2
        $warehouse->addRacks($racks);
48 2
        event(new WarehouseWasCreated($warehouse));
0 ignored issues
show
The call to WarehouseWasCreated::__construct() has too many arguments starting with $warehouse.

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...
49 2
    }
50
51
    /**
52
     * Update the warehouse.
53
     *
54
     * @param $id
55
     * @param Request $request
56
     */
57 1
    public function update(Request $request, $id)
58
    {
59 1
        $this->validate($request, [
60 1
            'name'             => 'required|string|max:255',
61
            'racks.*.id'       => 'exists:racks,id',
62
            'racks.*.name'     => 'required|string|max:255',
63
            'racks.*.make_id'  => 'required|exists:makes,id',
64
            'racks.*.capacity' => 'required|integer|min:1',
65
        ]);
66
67 1
        $warehouse = Warehouse::findOrFail($id);
68 1
        $warehouse->update($request->only(['name']));
69
70 1
        $racks = $request->input('racks', []);
71 1
        $warehouse->removeRacksNotIn($this->getIdsFrom($racks));
72 1
        $warehouse->addOrUpdateRacks($racks);
73 1
        event(new WarehouseWasUpdated($warehouse));
0 ignored issues
show
The call to WarehouseWasUpdated::__construct() has too many arguments starting with $warehouse.

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...
74 1
    }
75
76
    /**
77
     * Delete the warehouse.
78
     *
79
     * @param $id
80
     */
81 2
    public function destroy($id)
82
    {
83 2
        $warehouse = Warehouse::findOrFail($id);
84 2
        $warehouse->delete();
85 2
        event(new WarehouseWasDeleted($warehouse));
0 ignored issues
show
The call to WarehouseWasDeleted::__construct() has too many arguments starting with $warehouse.

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...
86 2
    }
87
88
    /**
89
     * @param $racks
90
     *
91
     * @return array
92
     */
93 1
    private function getIdsFrom($racks)
94
    {
95 1
        return array_filter(array_pluck($racks, 'id'));
96
    }
97
}
98