@@ -13,35 +13,35 @@ |
||
13 | 13 | * @var array |
14 | 14 | */ |
15 | 15 | protected $listen = [ |
16 | - 'App\Events\MakeWasCreated' => [], |
|
17 | - 'App\Events\MakeWasDeleted' => [], |
|
16 | + 'App\Events\MakeWasCreated' => [ ], |
|
17 | + 'App\Events\MakeWasDeleted' => [ ], |
|
18 | 18 | |
19 | - 'App\Events\ModelWasCreated' => [], |
|
20 | - 'App\Events\ModelWasDeleted' => [], |
|
19 | + 'App\Events\ModelWasCreated' => [ ], |
|
20 | + 'App\Events\ModelWasDeleted' => [ ], |
|
21 | 21 | |
22 | - 'App\Events\WarehouseWasCreated' => [], |
|
23 | - 'App\Events\WarehouseWasUpdated' => [], |
|
24 | - 'App\Events\WarehouseWasDeleted' => [], |
|
22 | + 'App\Events\WarehouseWasCreated' => [ ], |
|
23 | + 'App\Events\WarehouseWasUpdated' => [ ], |
|
24 | + 'App\Events\WarehouseWasDeleted' => [ ], |
|
25 | 25 | |
26 | - 'App\Events\SupplierWasCreated' => [], |
|
27 | - 'App\Events\SupplierWasDeleted' => [], |
|
26 | + 'App\Events\SupplierWasCreated' => [ ], |
|
27 | + 'App\Events\SupplierWasDeleted' => [ ], |
|
28 | 28 | |
29 | 29 | 'App\Events\PurchaseWasCreated' => [ |
30 | 30 | 'App\Listeners\GeneratePurchaseNotification', |
31 | 31 | ], |
32 | - 'App\Events\PurchaseWasDeleted' => [], |
|
32 | + 'App\Events\PurchaseWasDeleted' => [ ], |
|
33 | 33 | |
34 | 34 | 'App\Events\GuitarWasCreated' => [ |
35 | 35 | 'App\Listeners\GenerateRackNotification', |
36 | 36 | ], |
37 | - 'App\Events\GuitarWasUpdated' => [], |
|
38 | - 'App\Events\GuitarWasDeleted' => [], |
|
37 | + 'App\Events\GuitarWasUpdated' => [ ], |
|
38 | + 'App\Events\GuitarWasDeleted' => [ ], |
|
39 | 39 | |
40 | - 'App\Events\SaleWasCreated' => [], |
|
41 | - 'App\Events\SaleWasDeleted' => [], |
|
40 | + 'App\Events\SaleWasCreated' => [ ], |
|
41 | + 'App\Events\SaleWasDeleted' => [ ], |
|
42 | 42 | |
43 | - 'App\Events\NotificationWasCreated' => [], |
|
44 | - 'App\Events\NotificationWasDismissed' => [], |
|
43 | + 'App\Events\NotificationWasCreated' => [ ], |
|
44 | + 'App\Events\NotificationWasDismissed' => [ ], |
|
45 | 45 | ]; |
46 | 46 | |
47 | 47 | /** |
@@ -4,9 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use App\Guitar; |
6 | 6 | use App\Transformers\GuitarTransformer; |
7 | -use Illuminate\Http\Request; |
|
8 | - |
|
9 | -use App\Http\Requests; |
|
10 | 7 | use App\Http\Controllers\Controller; |
11 | 8 | |
12 | 9 | class GuitarController extends Controller |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | public function store($id, Request $request) |
45 | 45 | { |
46 | 46 | $purchase = Purchase::findOrFail($id); |
47 | - if ( ! $purchase->hasArrived() || ! $purchase->isPendingStorage()) { |
|
48 | - return response(['purchase' => ['The purchase has not yet arrived or doesn\'t require addition of guitars.']], |
|
47 | + if (!$purchase->hasArrived() || !$purchase->isPendingStorage()) { |
|
48 | + return response([ 'purchase' => [ 'The purchase has not yet arrived or doesn\'t require addition of guitars.' ] ], |
|
49 | 49 | 422); |
50 | 50 | } |
51 | 51 | |
52 | 52 | $this->validate($request, [ |
53 | - 'rack_id' => 'required|exists:racks,id,make_id,' . $purchase->make_id, |
|
54 | - 'model_id' => 'required|exists:models,id,make_id,' . $purchase->make_id, |
|
53 | + 'rack_id' => 'required|exists:racks,id,make_id,'.$purchase->make_id, |
|
54 | + 'model_id' => 'required|exists:models,id,make_id,'.$purchase->make_id, |
|
55 | 55 | 'colour' => 'required|string|max:255', |
56 | 56 | 'damaged' => 'boolean', |
57 | 57 | 'condition' => 'required_if:damaged,true', |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | |
61 | 61 | $rack = Rack::find($request->input('rack_id')); |
62 | 62 | if ($rack->used >= $rack->capacity) { |
63 | - return response(['rack_id' => ['The selected rack is full.']], 422); |
|
63 | + return response([ 'rack_id' => [ 'The selected rack is full.' ] ], 422); |
|
64 | 64 | } |
65 | 65 | |
66 | - $guitar = Guitar::create($request->only(['rack_id', 'model_id', 'colour', 'price']) + [ |
|
66 | + $guitar = Guitar::create($request->only([ 'rack_id', 'model_id', 'colour', 'price' ]) + [ |
|
67 | 67 | 'make_id' => $purchase->make_id, |
68 | 68 | 'purchase_id' => $purchase->id, |
69 | 69 | 'damaged' => $request->input('damaged'), |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | { |
86 | 86 | $guitar = Guitar::findOrFail($id); |
87 | 87 | $this->validate($request, [ |
88 | - 'rack_id' => 'required|exists:racks,id,make_id,' . $guitar->make_id, |
|
89 | - 'model_id' => 'required|exists:models,id,make_id,' . $guitar->make_id, |
|
88 | + 'rack_id' => 'required|exists:racks,id,make_id,'.$guitar->make_id, |
|
89 | + 'model_id' => 'required|exists:models,id,make_id,'.$guitar->make_id, |
|
90 | 90 | 'colour' => 'required|string|max:255', |
91 | 91 | 'damaged' => 'boolean', |
92 | 92 | 'condition' => 'required_if:damaged,true', |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | $rack = Rack::find($request->input('rack_id')); |
97 | 97 | if ($rack->used >= $rack->capacity) { |
98 | - return response(['rack_id' => ['The selected rack is full.']], 422); |
|
98 | + return response([ 'rack_id' => [ 'The selected rack is full.' ] ], 422); |
|
99 | 99 | } |
100 | 100 | |
101 | - $guitar->update($request->only(['rack_id', 'model_id', 'colour', 'price']) + [ |
|
101 | + $guitar->update($request->only([ 'rack_id', 'model_id', 'colour', 'price' ]) + [ |
|
102 | 102 | 'damaged' => $request->input('damaged'), |
103 | 103 | 'condition' => $request->input('damaged') ? $request->input('condition') : null |
104 | 104 | ]); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | $guitar = Guitar::findOrFail($id); |
116 | 116 | if ($guitar->isSold()) { |
117 | - return redirect('/sales/' . $guitar->sale->id); |
|
117 | + return redirect('/sales/'.$guitar->sale->id); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | abort(404); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $guitar = Guitar::findOrFail($id); |
134 | 134 | |
135 | 135 | if ($guitar->isSold()) { |
136 | - return response(['guitar_id' => ['This guitar has already been sold.']], 422); |
|
136 | + return response([ 'guitar_id' => [ 'This guitar has already been sold.' ] ], 422); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->validate($request, [ |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | |
145 | 145 | $shop = null; |
146 | 146 | if ($request->input('customer_type') == 'shop') { |
147 | - $shop = Shop::create($request->only(['name', 'address']))->id; |
|
147 | + $shop = Shop::create($request->only([ 'name', 'address' ]))->id; |
|
148 | 148 | } |
149 | 149 | |
150 | - $sale = Sale::create($request->only(['name', 'address']) + ['guitar_id' => $id, 'shop_id' => $shop]); |
|
150 | + $sale = Sale::create($request->only([ 'name', 'address' ]) + [ 'guitar_id' => $id, 'shop_id' => $shop ]); |
|
151 | 151 | |
152 | 152 | event(new SaleWasCreated($sale)); |
153 | 153 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -Route::group(['middleware' => 'web'], function ($router) { |
|
4 | - $router->get('/', function () { |
|
3 | +Route::group([ 'middleware' => 'web' ], function($router) { |
|
4 | + $router->get('/', function() { |
|
5 | 5 | return redirect('/dashboard'); |
6 | 6 | }); |
7 | 7 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | $router->put('api/notifications/{id}/dismiss', 'API\NotificationController@dismiss'); |
36 | 36 | $router->get('api/users/me', 'API\UserController@getCurrentUser'); |
37 | 37 | |
38 | - $router->resource('makes', 'MakeController', ['except' => ['create', 'show', 'edit', 'update']]); |
|
39 | - $router->resource('models', 'ModelController', ['except' => ['create', 'show', 'edit', 'update']]); |
|
40 | - $router->resource('purchases', 'PurchaseController', ['except' => ['create', 'edit', 'update']]); |
|
38 | + $router->resource('makes', 'MakeController', [ 'except' => [ 'create', 'show', 'edit', 'update' ] ]); |
|
39 | + $router->resource('models', 'ModelController', [ 'except' => [ 'create', 'show', 'edit', 'update' ] ]); |
|
40 | + $router->resource('purchases', 'PurchaseController', [ 'except' => [ 'create', 'edit', 'update' ] ]); |
|
41 | 41 | $router->post('purchases/{id}/guitars', 'GuitarController@store'); |
42 | - $router->resource('suppliers', 'SupplierController', ['except' => ['create', 'show', 'edit', 'update']]); |
|
43 | - $router->resource('warehouses', 'WarehouseController', ['except' => ['create', 'show', 'edit']]); |
|
44 | - $router->resource('guitars', 'GuitarController', ['only' => ['index', 'update', 'destroy']]); |
|
42 | + $router->resource('suppliers', 'SupplierController', [ 'except' => [ 'create', 'show', 'edit', 'update' ] ]); |
|
43 | + $router->resource('warehouses', 'WarehouseController', [ 'except' => [ 'create', 'show', 'edit' ] ]); |
|
44 | + $router->resource('guitars', 'GuitarController', [ 'only' => [ 'index', 'update', 'destroy' ] ]); |
|
45 | 45 | $router->get('guitars/{id}/sale', 'GuitarController@showSaleFor'); |
46 | 46 | $router->post('guitars/{id}/sale', 'GuitarController@sale'); |
47 | 47 | }); |