1 | <?php |
||
12 | class PurchaseController extends Controller |
||
13 | { |
||
14 | /** |
||
15 | * PurchaseController constructor. |
||
16 | */ |
||
17 | 10 | public function __construct() |
|
18 | { |
||
19 | 10 | $this->middleware('auth'); |
|
20 | 10 | } |
|
21 | |||
22 | /** |
||
23 | * Display a listing of the resource. |
||
24 | * |
||
25 | * @return \Illuminate\Http\Response |
||
26 | */ |
||
27 | 1 | public function index() |
|
28 | { |
||
29 | 1 | return view('purchases.index'); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Store a newly created resource in storage. |
||
34 | * |
||
35 | * @param \Illuminate\Http\Request $request |
||
36 | */ |
||
37 | 5 | public function store(Request $request) |
|
45 | |||
46 | /** |
||
47 | * Show the specified resource. |
||
48 | * |
||
49 | * @param $id |
||
50 | * |
||
51 | * @return mixed |
||
52 | */ |
||
53 | public function show($id) |
||
59 | |||
60 | /** |
||
61 | * Remove the specified resource from storage. |
||
62 | * |
||
63 | * @param int $id |
||
64 | */ |
||
65 | 1 | public function destroy($id) |
|
71 | |||
72 | /** |
||
73 | * Rules for validation depending whether or not supplier has been provided. |
||
74 | * |
||
75 | * @param int $supplierId |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | 5 | private function rules($supplierId) |
|
80 | { |
||
81 | $rules = [ |
||
82 | 5 | 'id' => 'integer|min:1|unique:suppliers,id', |
|
83 | 5 | 'make_id' => 'required|exists:makes,id', |
|
84 | 5 | 'quantity' => 'required|integer|min:1', |
|
85 | 5 | 'price' => 'required|numeric|min:1', |
|
86 | 5 | 'date_purchased' => 'required|date_format:Y-m-d|before:tomorrow', |
|
87 | 5 | 'delivery_date' => 'required|date_format:Y-m-d|after:date_purchased', |
|
88 | 5 | 'supplier.name' => 'required_if:supplier_id,new|string|max:255', |
|
89 | 5 | 'supplier.location' => 'required_if:supplier_id,new|string|max:255', |
|
90 | 5 | ]; |
|
91 | 5 | if ($supplierId != 'new') { |
|
92 | 4 | $rules += ['supplier_id' => 'required|integer|exists:suppliers,id']; |
|
93 | 4 | } |
|
94 | |||
95 | 5 | return $rules; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * Get the supplier depending on the request. |
||
100 | * |
||
101 | * @param Request $request |
||
102 | * |
||
103 | * @return Supplier |
||
104 | */ |
||
105 | 1 | private function getSupplier(Request $request) |
|
118 | } |
||
119 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: