@@ -6,7 +6,6 @@ |
||
6 | 6 | use App\Repositories\LotRepository; |
7 | 7 | use App\Repositories\ProfileRepository; |
8 | 8 | use App\Repositories\InvolvedRepository; |
9 | -use Carbon\Carbon; |
|
10 | 9 | use Illuminate\Contracts\Auth\Guard; |
11 | 10 | use App\Http\Requests\UpdateUserSettings; |
12 | 11 | use App\Http\Requests\UpdateUserPassword; |
@@ -106,13 +106,13 @@ |
||
106 | 106 | if (count($involved)) { |
107 | 107 | foreach ($involved as $item) { |
108 | 108 | if ($item->lot->verify_status == 'verified') { |
109 | - $product[] = ['date' =>$item->lot->public_date, 'product' => $item->product, 'involved' => $item]; |
|
110 | - }else { |
|
111 | - $product[] = ['date' =>date('dmy',strtotime('9999999')), 'product' => $item->product, 'involved' => $item]; |
|
109 | + $product[ ] = [ 'date' =>$item->lot->public_date, 'product' => $item->product, 'involved' => $item ]; |
|
110 | + } else { |
|
111 | + $product[ ] = [ 'date' =>date('dmy', strtotime('9999999')), 'product' => $item->product, 'involved' => $item ]; |
|
112 | 112 | } |
113 | 113 | } |
114 | - usort($product, function ($product, $b) { |
|
115 | - return date('dmy',strtotime($b['date'])) - date('dmy',strtotime($product['date'])); |
|
114 | + usort($product, function($product, $b) { |
|
115 | + return date('dmy', strtotime($b[ 'date' ])) - date('dmy', strtotime($product[ 'date' ])); |
|
116 | 116 | }); |
117 | 117 | |
118 | 118 | return $product; |
@@ -107,7 +107,7 @@ |
||
107 | 107 | foreach ($involved as $item) { |
108 | 108 | if ($item->lot->verify_status == 'verified') { |
109 | 109 | $product[] = ['date' =>$item->lot->public_date, 'product' => $item->product, 'involved' => $item]; |
110 | - }else { |
|
110 | + } else { |
|
111 | 111 | $product[] = ['date' =>date('dmy',strtotime('9999999')), 'product' => $item->product, 'involved' => $item]; |
112 | 112 | } |
113 | 113 | } |
@@ -16,8 +16,6 @@ |
||
16 | 16 | use Illuminate\Contracts\Auth\Guard; |
17 | 17 | use Illuminate\Http\Request; |
18 | 18 | |
19 | -use App\Http\Requests; |
|
20 | - |
|
21 | 19 | class LotsController extends Controller |
22 | 20 | { |
23 | 21 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'sub_category' => $sub_category, |
148 | 148 | 'respons' => true |
149 | 149 | ); |
150 | - return response($json); |
|
150 | + return response($json); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function index() |
233 | 233 | { |
234 | - /* dd(Lot::all());*/ |
|
234 | + /* dd(Lot::all());*/ |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $lot = $this->lots->addLot($vendor); |
92 | 92 | $delivery = $this->method->getPublic('delivery'); |
93 | 93 | $payment = $this->method->getPublic('payment'); |
94 | - return view('lots.create', compact('lot','delivery','payment')); |
|
94 | + return view('lots.create', compact('lot', 'delivery', 'payment')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | //dd($lot->lotDeliveryPayment()); |
104 | 104 | $delivery = $this->method->getPublic('delivery'); |
105 | 105 | $payment = $this->method->getPublic('payment'); |
106 | - return view('lots.create', compact('lot','delivery','payment')); |
|
106 | + return view('lots.create', compact('lot', 'delivery', 'payment')); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function loadProductBlock(Request $request, Lot $lot) |
161 | 161 | { |
162 | - if($lot->category_id) { |
|
162 | + if ($lot->category_id) { |
|
163 | 163 | $product = $this->products->createPlain($lot); |
164 | 164 | |
165 | - return view('lots.partials.form.product', ['product' => $product, 'lot' => $lot]); |
|
165 | + return view('lots.partials.form.product', [ 'product' => $product, 'lot' => $lot ]); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return 'false'; |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | public function updateLot(SaveLotRequest $request, Lot $lot) |
205 | 205 | { |
206 | 206 | $lot = $this->lots->save($lot, $request->all()); |
207 | - $method = []; |
|
207 | + $method = [ ]; |
|
208 | 208 | if ($request->input('method')) { |
209 | - $method = $request->input('method'); |
|
209 | + $method = $request->input('method'); |
|
210 | 210 | } |
211 | 211 | $lotMethod = $this->lot_method->save($lot, $method); |
212 | 212 | return response(array('respons'=>true)); |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | public function publishedLot(SaveLotRequest $request, Lot $lot) |
217 | 217 | { |
218 | 218 | $lot = $this->lots->save($lot, $request->all()); |
219 | - $method = []; |
|
219 | + $method = [ ]; |
|
220 | 220 | if ($request->input('method')) { |
221 | - $method = $request->input('method'); |
|
221 | + $method = $request->input('method'); |
|
222 | 222 | } |
223 | 223 | $lotMethod = $this->lot_method->save($lot, $method); |
224 | 224 | |
225 | - return response(array('respons'=>true,'status'=>$lot->status)); |
|
225 | + return response(array('respons'=>true, 'status'=>$lot->status)); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 |
@@ -6,8 +6,6 @@ |
||
6 | 6 | use App\Repositories\LotRepository; |
7 | 7 | use App\Repositories\ProductsRepository; |
8 | 8 | use App\Repositories\PagesRepository; |
9 | -use App\Repositories\VendorRepository; |
|
10 | -use Illuminate\Http\Request; |
|
11 | 9 | |
12 | 10 | class PagesController extends Controller |
13 | 11 | { |
@@ -56,7 +56,7 @@ |
||
56 | 56 | */ |
57 | 57 | public function show($page) |
58 | 58 | { |
59 | - return view('pages.show', ['item' => $page]); |
|
59 | + return view('pages.show', [ 'item' => $page ]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @param SaveProductRequest $request |
103 | 103 | * @param Product $product |
104 | - * @return mixed |
|
104 | + * @return \Symfony\Component\HttpFoundation\Response |
|
105 | 105 | */ |
106 | 106 | public function save(SaveProductRequest $request, Lot $lot, Product $product) |
107 | 107 | { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param Request $request |
209 | 209 | * @param Lot $lot |
210 | 210 | * |
211 | - * @return string |
|
211 | + * @return \Symfony\Component\HttpFoundation\Response |
|
212 | 212 | */ |
213 | 213 | public function remove(Request $request, Lot $lot) |
214 | 214 | { |
@@ -245,6 +245,9 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | + /** |
|
249 | + * @param SaveProductRequest $request |
|
250 | + */ |
|
248 | 251 | private function saveSpecificationsPrice($request, Product $product) |
249 | 252 | { |
250 | 253 | //dd($request->get('spec_price')); |
@@ -299,7 +302,7 @@ discard block |
||
299 | 302 | * |
300 | 303 | * @param Request $request |
301 | 304 | * |
302 | - * @return void |
|
305 | + * @return \Symfony\Component\HttpFoundation\Response |
|
303 | 306 | */ |
304 | 307 | public function removeSpec(Request $request) |
305 | 308 | { |
@@ -340,7 +343,7 @@ discard block |
||
340 | 343 | * @param $image |
341 | 344 | * @param Product $product |
342 | 345 | * |
343 | - * @return mixed |
|
346 | + * @return Image|null |
|
344 | 347 | */ |
345 | 348 | public function addImage($image, Product $product) |
346 | 349 | { |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Http\Controllers; |
4 | 4 | |
5 | -use App\Http\Requests\ProductCreateRequest; |
|
6 | -use App\Http\Requests\ProductUpdateRequest; |
|
7 | 5 | use App\Http\Requests\SaveProductRequest; |
8 | 6 | use App\Image; |
9 | 7 | use App\ImprovedSpec; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $this->addImage($image, $product); |
119 | 119 | }); |
120 | 120 | |
121 | - /* if (!empty($specs = $request->get('i_spec'))) |
|
121 | + /* if (!empty($specs = $request->get('i_spec'))) |
|
122 | 122 | $this->saveImprovedSpecifications($specs, $product);*/ |
123 | 123 | |
124 | 124 | $json = array( |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | //dd($request->get('spec_price')); |
251 | 251 | //dd(collect($request->get('spec_price'))->first()); |
252 | 252 | //$collection = $request->get('spec_price'); |
253 | - /* $collection = collect($request->get('spec_price')); |
|
253 | + /* $collection = collect($request->get('spec_price')); |
|
254 | 254 | $filtered = $collection->filter(function ($item) { |
255 | 255 | return $item['new_price'] != '' && $item['old_price'] != ''; |
256 | 256 | })->values(); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $product = $this->products->saveProduct($product, $request->all()); |
109 | 109 | |
110 | 110 | if (!empty($spec_price = $request->get('spec_price'))) |
111 | - $this->saveSpecificationsPrice($request,$product); |
|
111 | + $this->saveSpecificationsPrice($request, $product); |
|
112 | 112 | |
113 | 113 | if (!empty($spec = $request->get('spec'))) |
114 | 114 | $this->saveSpecifications($spec, $product); |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | $lot = $this->lots->find($product->lot_id); |
141 | 141 | $productInLot = $this->products->countInLotProduct($product->lot_id); |
142 | 142 | $same_products = $this->products->getSameProduct($product->sub_category_id); |
143 | - $view = view('product.show',['item'=>$product,'lot'=>$lot,'similar'=>$same_products ,'productItem'=> $itemPercentage,'productinlot'=>$productInLot]); |
|
143 | + $view = view('product.show', [ 'item'=>$product, 'lot'=>$lot, 'similar'=>$same_products, 'productItem'=> $itemPercentage, 'productinlot'=>$productInLot ]); |
|
144 | 144 | |
145 | - if(Auth::check()) { |
|
145 | + if (Auth::check()) { |
|
146 | 146 | $auth_is_involved = $this->involved |
147 | 147 | ->checkIfAuthInvolved($product); |
148 | 148 | |
@@ -179,24 +179,24 @@ discard block |
||
179 | 179 | { |
180 | 180 | $count = $this->products->getCount($id); |
181 | 181 | $selled = $this->involved->getCountSelled($id); |
182 | - ($count) ? $result = number_format((100 * $selled) / $count) : $result = 0; |
|
182 | + ($count) ? $result = number_format((100 * $selled) / $count) : $result = 0; |
|
183 | 183 | |
184 | - return array(['totalItems'=>$count,'salePercent'=>$result]); |
|
184 | + return array([ 'totalItems'=>$count, 'salePercent'=>$result ]); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | public function getSpecifications() { |
189 | 189 | |
190 | - $request = \Request::all(); |
|
191 | - $getSpecification = $this->improvedSpecs->getById($request['id']); |
|
190 | + $request = \Request::all(); |
|
191 | + $getSpecification = $this->improvedSpecs->getById($request[ 'id' ]); |
|
192 | 192 | |
193 | 193 | return json_encode($getSpecification); |
194 | 194 | } |
195 | 195 | |
196 | 196 | public function getSpecificationsColor() { |
197 | 197 | |
198 | - $request = \Request::all(); |
|
199 | - $getSpecificationColor = $this->modelColors->getById($request['id']); |
|
198 | + $request = \Request::all(); |
|
199 | + $getSpecificationColor = $this->modelColors->getById($request[ 'id' ]); |
|
200 | 200 | |
201 | 201 | return json_encode($getSpecificationColor); |
202 | 202 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function remove(Request $request, Lot $lot) |
214 | 214 | { |
215 | - $product = $this->products->find($request->get('product_id')); |
|
215 | + $product = $this->products->find($request->get('product_id')); |
|
216 | 216 | if ($product) { |
217 | 217 | foreach ($product->specPrice as $key => $price) { |
218 | 218 | $price->removeMetaGroupById('price', $price->id); |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | */ |
238 | 238 | private function saveSpecifications($specifications, Product $product) |
239 | 239 | { |
240 | - array_walk($specifications, function ($meta) use ($product) { |
|
241 | - if ($meta['key'] != null && $meta['value'] != null) { |
|
240 | + array_walk($specifications, function($meta) use ($product) { |
|
241 | + if ($meta[ 'key' ] != null && $meta[ 'value' ] != null) { |
|
242 | 242 | $product->setMeta($meta, 'spec'); |
243 | 243 | } |
244 | 244 | }); |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | dd($filtered->all());*/ |
258 | 258 | if (!empty($spec = $request->get('spec_price'))) { |
259 | 259 | foreach ($spec as $key => $price) { |
260 | - if (($price['new_price'] >= 0 && $price['old_price'] >= 0) && ($price['new_price'] != null && $price['old_price'] != null)) { |
|
260 | + if (($price[ 'new_price' ] >= 0 && $price[ 'old_price' ] >= 0) && ($price[ 'new_price' ] != null && $price[ 'old_price' ] != null)) { |
|
261 | 261 | $specPriceInsert = $this->specPrice->save($price, $product); |
262 | - if (!empty($specMeta = $price['spec_desc'])) { |
|
262 | + if (!empty($specMeta = $price[ 'spec_desc' ])) { |
|
263 | 263 | foreach ($specMeta as $meta) { |
264 | - if ($meta['key'] != null && $meta['value'] != null) { |
|
264 | + if ($meta[ 'key' ] != null && $meta[ 'value' ] != null) { |
|
265 | 265 | $specPriceInsert->setMeta($meta, 'price'); |
266 | 266 | } |
267 | 267 | } |
268 | 268 | } |
269 | - if (!empty($specSize = $price['size'])) { |
|
269 | + if (!empty($specSize = $price[ 'size' ])) { |
|
270 | 270 | foreach ($specSize as $key => $size) { |
271 | - if ($size['size'] >= 0 && $size['size'] != null) { |
|
271 | + if ($size[ 'size' ] >= 0 && $size[ 'size' ] != null) { |
|
272 | 272 | $specSizeInsert = $this->improvedSpecs->save($size, $specPriceInsert); |
273 | - if (!empty($specColor = $size['color'])) { |
|
273 | + if (!empty($specColor = $size[ 'color' ])) { |
|
274 | 274 | foreach ($specColor as $key => $color) { |
275 | - if ($color['color_hash'] != null or ($color['amount'] >= 0 && $color['amount'] != null)) { |
|
275 | + if ($color[ 'color_hash' ] != null or ($color[ 'amount' ] >= 0 && $color[ 'amount' ] != null)) { |
|
276 | 276 | $specColorInsert = $this->modelColors->save($color, $specSizeInsert); |
277 | 277 | } |
278 | 278 | } |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | |
288 | 288 | private function saveImprovedSpecifications($specs, $product) |
289 | 289 | { |
290 | - array_walk($specs, function($data, $product){ |
|
290 | + array_walk($specs, function($data, $product) { |
|
291 | 291 | $spec = $this->improvedSpecs->find($spec_id); |
292 | - if($spec) |
|
292 | + if ($spec) |
|
293 | 293 | $this->improvedSpecs->update($spec, $data); |
294 | 294 | }); |
295 | 295 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | public function addImage($image, Product $product) |
346 | 346 | { |
347 | 347 | if ($image instanceof UploadedFile) { |
348 | - $location = 'upload/products/' . $product->id; |
|
348 | + $location = 'upload/products/'.$product->id; |
|
349 | 349 | $processor = new ImageProcessor(); |
350 | 350 | $imageable = $processor->uploadAndCreate($image, $product, null, $location); |
351 | 351 | |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | { |
375 | 375 | $sorted = $request->get('item'); |
376 | 376 | |
377 | - $newsort = []; |
|
378 | - array_walk($sorted, function ($id, $k) use (&$newsort){ |
|
377 | + $newsort = [ ]; |
|
378 | + array_walk($sorted, function($id, $k) use (&$newsort){ |
|
379 | 379 | $image = Image::find($id); |
380 | 380 | |
381 | - $newsort[$k] = ['id' => $image->id, 'rank' => $image->rank]; |
|
381 | + $newsort[ $k ] = [ 'id' => $image->id, 'rank' => $image->rank ]; |
|
382 | 382 | }); |
383 | 383 | |
384 | - $oldsort = []; |
|
385 | - $product->images()->ranked('asc')->get()->each(function ($item, $k) use(&$oldsort) |
|
384 | + $oldsort = [ ]; |
|
385 | + $product->images()->ranked('asc')->get()->each(function($item, $k) use(&$oldsort) |
|
386 | 386 | { |
387 | - $oldsort[$k] = ['id' => $item->id, 'rank' => $item->rank]; |
|
387 | + $oldsort[ $k ] = [ 'id' => $item->id, 'rank' => $item->rank ]; |
|
388 | 388 | }); |
389 | 389 | |
390 | 390 | $this->setNewRankToChangedPositions( |
@@ -403,12 +403,12 @@ discard block |
||
403 | 403 | */ |
404 | 404 | private function getChangedSortPositions($newsort, $oldsort) |
405 | 405 | { |
406 | - $temp = []; |
|
407 | - array_walk($newsort, function ($sorted_attribs, $position) use ($oldsort, $newsort, &$temp) |
|
406 | + $temp = [ ]; |
|
407 | + array_walk($newsort, function($sorted_attribs, $position) use ($oldsort, $newsort, &$temp) |
|
408 | 408 | { |
409 | - if($oldsort[$position]['id'] !== $newsort[$position]['id']) |
|
409 | + if ($oldsort[ $position ][ 'id' ] !== $newsort[ $position ][ 'id' ]) |
|
410 | 410 | { |
411 | - $temp[] = $position; |
|
411 | + $temp[ ] = $position; |
|
412 | 412 | } |
413 | 413 | }); |
414 | 414 | |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | */ |
425 | 425 | private function setNewRankToChangedPositions($changed_positions, $newsort, $oldsort) |
426 | 426 | { |
427 | - array_walk($changed_positions, function ($position) use ($oldsort, $newsort) |
|
427 | + array_walk($changed_positions, function($position) use ($oldsort, $newsort) |
|
428 | 428 | { |
429 | - $image = Image::find($newsort[$position]['id']); |
|
429 | + $image = Image::find($newsort[ $position ][ 'id' ]); |
|
430 | 430 | |
431 | - $image->setRank($oldsort[$position]['rank']); |
|
431 | + $image->setRank($oldsort[ $position ][ 'rank' ]); |
|
432 | 432 | }); |
433 | 433 | } |
434 | 434 | |
@@ -439,31 +439,31 @@ discard block |
||
439 | 439 | $key_spec = ($request->has('key_spec')) ? $request->get('key_spec') : 1; |
440 | 440 | $product = $this->products->find($request->get('product_id')); |
441 | 441 | $currencies = $this->currencies->getPublic(); |
442 | - return view('lots.partials.form.specification_price', ['currencies' => $currencies,'lot' => $lot,'product' => $product,'key_spec' => $key_spec]); |
|
442 | + return view('lots.partials.form.specification_price', [ 'currencies' => $currencies, 'lot' => $lot, 'product' => $product, 'key_spec' => $key_spec ]); |
|
443 | 443 | } |
444 | 444 | public function loadSpecPriceDescription(Request $request) |
445 | 445 | { |
446 | 446 | $key_desc = ($request->has('key_desc')) ? $request->get('key_desc') : 1; |
447 | 447 | $key_spec = ($request->has('key_spec')) ? $request->get('key_spec') : 1; |
448 | - return view('lots.partials.form.description_specs', ['key_spec' => $key_spec,'key_desc' => $key_desc]); |
|
448 | + return view('lots.partials.form.description_specs', [ 'key_spec' => $key_spec, 'key_desc' => $key_desc ]); |
|
449 | 449 | } |
450 | 450 | public function loadImprovedSpecPrice(Request $request) |
451 | 451 | { |
452 | 452 | $key_spec = ($request->has('key_spec')) ? $request->get('key_spec') : 1; |
453 | 453 | $key_size = ($request->has('key_size')) ? $request->get('key_size') : 1; |
454 | - return view('lots.partials.form.size_specs', ['key_spec' => $key_spec,'key_size' => $key_size]); |
|
454 | + return view('lots.partials.form.size_specs', [ 'key_spec' => $key_spec, 'key_size' => $key_size ]); |
|
455 | 455 | } |
456 | 456 | public function loadSpecPriceColor(Request $request) |
457 | 457 | { |
458 | 458 | $key_spec = ($request->has('key_spec')) ? $request->get('key_spec') : 1; |
459 | 459 | $key_size = ($request->has('key_size')) ? $request->get('key_size') : 1; |
460 | 460 | $key_color = ($request->has('key_color')) ? $request->get('key_color') : 1; |
461 | - return view('lots.partials.form.color_specs', ['key_spec' => $key_spec,'key_size' => $key_size,'key_color' => $key_color]); |
|
461 | + return view('lots.partials.form.color_specs', [ 'key_spec' => $key_spec, 'key_size' => $key_size, 'key_color' => $key_color ]); |
|
462 | 462 | } |
463 | 463 | public function loadSpec(Request $request) |
464 | 464 | { |
465 | - $key_spec_product = ($request->has('key_spec_product')) ? $request->get('key_spec_product') : 1; |
|
466 | - return view('lots.partials.form.specification', ['key_spec_product' => $key_spec_product]); |
|
465 | + $key_spec_product = ($request->has('key_spec_product')) ? $request->get('key_spec_product') : 1; |
|
466 | + return view('lots.partials.form.specification', [ 'key_spec_product' => $key_spec_product ]); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | public function removeGroupPrice(Request $request) |
@@ -107,15 +107,18 @@ discard block |
||
107 | 107 | { |
108 | 108 | $product = $this->products->saveProduct($product, $request->all()); |
109 | 109 | |
110 | - if (!empty($spec_price = $request->get('spec_price'))) |
|
111 | - $this->saveSpecificationsPrice($request,$product); |
|
110 | + if (!empty($spec_price = $request->get('spec_price'))) { |
|
111 | + $this->saveSpecificationsPrice($request,$product); |
|
112 | + } |
|
112 | 113 | |
113 | - if (!empty($spec = $request->get('spec'))) |
|
114 | - $this->saveSpecifications($spec, $product); |
|
114 | + if (!empty($spec = $request->get('spec'))) { |
|
115 | + $this->saveSpecifications($spec, $product); |
|
116 | + } |
|
115 | 117 | |
116 | - if (!empty($fileInput = $request->file('image'))) |
|
117 | - array_walk($fileInput, function($image) use (&$product){ |
|
118 | + if (!empty($fileInput = $request->file('image'))) { |
|
119 | + array_walk($fileInput, function($image) use (&$product){ |
|
118 | 120 | $this->addImage($image, $product); |
121 | + } |
|
119 | 122 | }); |
120 | 123 | |
121 | 124 | /* if (!empty($specs = $request->get('i_spec'))) |
@@ -289,8 +292,9 @@ discard block |
||
289 | 292 | { |
290 | 293 | array_walk($specs, function($data, $product){ |
291 | 294 | $spec = $this->improvedSpecs->find($spec_id); |
292 | - if($spec) |
|
293 | - $this->improvedSpecs->update($spec, $data); |
|
295 | + if($spec) { |
|
296 | + $this->improvedSpecs->update($spec, $data); |
|
297 | + } |
|
294 | 298 | }); |
295 | 299 | } |
296 | 300 |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use App\Repositories\InvolvedRepository; |
8 | 8 | use App\Repositories\LotRepository; |
9 | 9 | use App\Repositories\SpecPriceRepository; |
10 | -use Illuminate\Http\Request; |
|
11 | 10 | |
12 | 11 | class UsersController extends Controller |
13 | 12 | { |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | |
57 | 57 | if ($selledPrice >= $product->lot->yield_amount) { |
58 | 58 | |
59 | - $product->lot->update(['verify_status' => 'expired']); |
|
59 | + $product->lot->update([ 'verify_status' => 'expired' ]); |
|
60 | 60 | |
61 | - return redirect()->back()->with(['status' => 'Oferta este finisata!', 'color' => 'green']); |
|
61 | + return redirect()->back()->with([ 'status' => 'Oferta este finisata!', 'color' => 'green' ]); |
|
62 | 62 | } |
63 | 63 | |
64 | - return redirect()->back()->with(['status' => 'Success! You are involve the product offer.', 'color' => 'green']); |
|
64 | + return redirect()->back()->with([ 'status' => 'Success! You are involve the product offer.', 'color' => 'green' ]); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | { |
76 | 76 | $selledPrice = $this->countInvolvedLot($product); |
77 | 77 | |
78 | - $involve = $this->involved->update($involve, ['active' => 0]); |
|
78 | + $involve = $this->involved->update($involve, [ 'active' => 0 ]); |
|
79 | 79 | |
80 | 80 | $remaining = config('product.times') - $this->involved->getInvolveTimesProduct($involve->product); |
81 | 81 | |
82 | 82 | if ($selledPrice < $product->lot->yield_amount) { |
83 | - $product->lot->update(['verify_status' => 'verified']); |
|
83 | + $product->lot->update([ 'verify_status' => 'verified' ]); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - return redirect()->back()->with(['status'=>'Success! You are exit from product offer. Remaining attempts (' . $remaining . ')','color'=>'green']); |
|
87 | + return redirect()->back()->with([ 'status'=>'Success! You are exit from product offer. Remaining attempts ('.$remaining.')', 'color'=>'green' ]); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $count = $product->lot->involved; |
97 | 97 | |
98 | 98 | foreach ($count as $item) { |
99 | - $changes[] = $item->count * $this->specs->getPriceById($item->price_id); |
|
99 | + $changes[ ] = $item->count * $this->specs->getPriceById($item->price_id); |
|
100 | 100 | } |
101 | 101 | return array_sum($changes); |
102 | 102 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace App\Http\Requests; |
4 | 4 | |
5 | 5 | use App\Repositories\InvolvedRepository; |
6 | -use Illuminate\Support\Facades\Auth; |
|
7 | 6 | |
8 | 7 | class InvolveProductRequest extends Request |
9 | 8 | { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function authorize() |
14 | 14 | { |
15 | 15 | $product = $this->route()->getParameter('product'); |
16 | - /* if ($product) { |
|
16 | + /* if ($product) { |
|
17 | 17 | if (! $this->getInvolvedRepository()->checkIfAuthInvolved($product)) |
18 | 18 | return true; |
19 | 19 | }*/ |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Http\ViewComposers; |
4 | 4 | |
5 | -use App\Product; |
|
6 | 5 | use App\Repositories\CategoryRepository; |
7 | 6 | use App\Repositories\PostsRepository; |
8 | 7 | use App\Repositories\ProductsRepository; |
@@ -59,41 +59,41 @@ discard block |
||
59 | 59 | ->with('popular_category', $this->categories->getPopularCategory()) |
60 | 60 | ->with('recommended', [ |
61 | 61 | 'name' => 'oferte recomandate', |
62 | - 'data' => function () { |
|
62 | + 'data' => function() { |
|
63 | 63 | return $this->products->getFeaturedPublic(5); |
64 | 64 | } |
65 | 65 | ]) |
66 | 66 | ->with('posts', [ |
67 | 67 | 'name' => 'articole de blog', |
68 | - 'data' => function (){ |
|
68 | + 'data' => function() { |
|
69 | 69 | return $this->posts->getPopularPublic(); |
70 | 70 | } |
71 | 71 | ]) |
72 | 72 | ->with('expire', [ |
73 | 73 | 'name' => 'produse care expira in curand', |
74 | 74 | 'label' => 'info_corner.png', |
75 | - 'data' => function ($count = 8) { |
|
75 | + 'data' => function($count = 8) { |
|
76 | 76 | return $this->products->getPublicExpireSoon($count); |
77 | 77 | } |
78 | 78 | ]) |
79 | 79 | ->with('popular', [ |
80 | 80 | 'name' => 'produse populare', |
81 | - 'data' => function () { |
|
81 | + 'data' => function() { |
|
82 | 82 | return $this->products->getFeaturedPublic(8); |
83 | 83 | } |
84 | 84 | ]) |
85 | 85 | ->with('category_1', [ |
86 | 86 | 'name' => ($category_1) ? $category_1->name : '', |
87 | - 'data' => function () use ($category_1){ |
|
88 | - $products = []; |
|
87 | + 'data' => function() use ($category_1){ |
|
88 | + $products = [ ]; |
|
89 | 89 | |
90 | - if($category_1) |
|
90 | + if ($category_1) |
|
91 | 91 | $category_1->categoryables() |
92 | 92 | ->active() |
93 | 93 | ->elementType(get_class($this->products->getModel())) |
94 | 94 | ->get() |
95 | - ->each(function ($morph) use (&$products) { |
|
96 | - $products[] = $morph->categoryable; |
|
95 | + ->each(function($morph) use (&$products) { |
|
96 | + $products[ ] = $morph->categoryable; |
|
97 | 97 | }); |
98 | 98 | |
99 | 99 | return $products; |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | ]) |
102 | 102 | ->with('category_2', [ |
103 | 103 | 'name' => ($category_2) ? $category_2->name : '', |
104 | - 'data' => function () use ($category_2){ |
|
105 | - $products = []; |
|
104 | + 'data' => function() use ($category_2){ |
|
105 | + $products = [ ]; |
|
106 | 106 | |
107 | - if($category_2) |
|
107 | + if ($category_2) |
|
108 | 108 | $category_2->categoryables() |
109 | 109 | ->active() |
110 | 110 | ->elementType(get_class($this->products->getModel())) |
111 | 111 | ->get() |
112 | - ->each(function ($morph) use (&$products) { |
|
113 | - $products[] = $morph->categoryable; |
|
112 | + ->each(function($morph) use (&$products) { |
|
113 | + $products[ ] = $morph->categoryable; |
|
114 | 114 | }); |
115 | 115 | |
116 | 116 | return $products; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ]) |
119 | 119 | ->with('latest', [ |
120 | 120 | 'name' => 'latest', |
121 | - 'data' => function () { |
|
121 | + 'data' => function() { |
|
122 | 122 | return $this->products->getPublicLatest(); |
123 | 123 | } |
124 | 124 | ]); |
@@ -87,13 +87,14 @@ discard block |
||
87 | 87 | 'data' => function () use ($category_1){ |
88 | 88 | $products = []; |
89 | 89 | |
90 | - if($category_1) |
|
91 | - $category_1->categoryables() |
|
90 | + if($category_1) { |
|
91 | + $category_1->categoryables() |
|
92 | 92 | ->active() |
93 | 93 | ->elementType(get_class($this->products->getModel())) |
94 | 94 | ->get() |
95 | 95 | ->each(function ($morph) use (&$products) { |
96 | 96 | $products[] = $morph->categoryable; |
97 | + } |
|
97 | 98 | }); |
98 | 99 | |
99 | 100 | return $products; |
@@ -104,13 +105,14 @@ discard block |
||
104 | 105 | 'data' => function () use ($category_2){ |
105 | 106 | $products = []; |
106 | 107 | |
107 | - if($category_2) |
|
108 | - $category_2->categoryables() |
|
108 | + if($category_2) { |
|
109 | + $category_2->categoryables() |
|
109 | 110 | ->active() |
110 | 111 | ->elementType(get_class($this->products->getModel())) |
111 | 112 | ->get() |
112 | 113 | ->each(function ($morph) use (&$products) { |
113 | 114 | $products[] = $morph->categoryable; |
115 | + } |
|
114 | 116 | }); |
115 | 117 | |
116 | 118 | return $products; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @param View $view |
26 | - * @return $this |
|
26 | + * @return View|null |
|
27 | 27 | */ |
28 | 28 | public function compose(View $view) |
29 | 29 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param $key |
36 | 36 | * @param $value |
37 | - * @param null $group |
|
37 | + * @param string $group |
|
38 | 38 | * @return mixed |
39 | 39 | */ |
40 | 40 | public function setMeta($meta_data, $group = null) |
@@ -111,6 +111,10 @@ discard block |
||
111 | 111 | $this->getRepository()->removeByKey($key); |
112 | 112 | } |
113 | 113 | } |
114 | + |
|
115 | + /** |
|
116 | + * @param string $group |
|
117 | + */ |
|
114 | 118 | public function removeMetaGroupById($group=null, $id=null) |
115 | 119 | { |
116 | 120 | if ($id!=null) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function setMeta($meta_data, $group = null) |
41 | 41 | { |
42 | - if (!$meta = $this->getMeta($meta_data['key_unique'], $group)) { |
|
42 | + if (!$meta = $this->getMeta($meta_data[ 'key_unique' ], $group)) { |
|
43 | 43 | return $this->getRepository()->create($this, $meta_data, $group); |
44 | 44 | } else { |
45 | 45 | return $this->updateMeta($meta, $meta_data); |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function updateMeta($meta, $meta_data, $group = null) |
59 | 59 | { |
60 | - if(is_numeric($meta)) |
|
60 | + if (is_numeric($meta)) |
|
61 | 61 | $meta = $this->getRepository()->getModel()->find((int) $meta)->first(); |
62 | 62 | |
63 | - $meta->key = $meta_data['key']; |
|
64 | - $meta->value = $meta_data['value']; |
|
65 | - if(isset($group)) |
|
63 | + $meta->key = $meta_data[ 'key' ]; |
|
64 | + $meta->value = $meta_data[ 'value' ]; |
|
65 | + if (isset($group)) |
|
66 | 66 | $meta->group = $group; |
67 | 67 | |
68 | 68 | $meta->save(); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function removeMeta($meta_data, $group = null) |
92 | 92 | { |
93 | - if(isset($group)) |
|
94 | - return $this->unsetMeta($meta_data['key_unique'], $group); |
|
93 | + if (isset($group)) |
|
94 | + return $this->unsetMeta($meta_data[ 'key_unique' ], $group); |
|
95 | 95 | |
96 | - return $this->unsetMeta($meta_data['key_unique']); |
|
96 | + return $this->unsetMeta($meta_data[ 'key_unique' ]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | $this->getRepository()->removeByKey($key); |
112 | 112 | } |
113 | 113 | } |
114 | - public function removeMetaGroupById($group=null, $id=null) |
|
114 | + public function removeMetaGroupById($group = null, $id = null) |
|
115 | 115 | { |
116 | - if ($id!=null) { |
|
117 | - $this->getRepository()->removeGroupById($group,(int)$id); |
|
116 | + if ($id != null) { |
|
117 | + $this->getRepository()->removeGroupById($group, (int) $id); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function removeMetaGroups($groups) |
128 | 128 | { |
129 | - if(is_array($groups)) { |
|
130 | - array_walk($groups, function ($group) { |
|
129 | + if (is_array($groups)) { |
|
130 | + array_walk($groups, function($group) { |
|
131 | 131 | $this->getRepository()->removeGroup($group); |
132 | 132 | }); |
133 | 133 | } else { |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function getMeta($key, $group = null) |
25 | 25 | { |
26 | - if (is_null($group)) |
|
27 | - return $this->meta()->whereKeyUnique($key)->first(); |
|
26 | + if (is_null($group)) { |
|
27 | + return $this->meta()->whereKeyUnique($key)->first(); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | return $this->meta()->whereKeyUnique($key)->group($group)->first(); |
30 | 31 | } |
@@ -57,13 +58,15 @@ discard block |
||
57 | 58 | */ |
58 | 59 | public function updateMeta($meta, $meta_data, $group = null) |
59 | 60 | { |
60 | - if(is_numeric($meta)) |
|
61 | - $meta = $this->getRepository()->getModel()->find((int) $meta)->first(); |
|
61 | + if(is_numeric($meta)) { |
|
62 | + $meta = $this->getRepository()->getModel()->find((int) $meta)->first(); |
|
63 | + } |
|
62 | 64 | |
63 | 65 | $meta->key = $meta_data['key']; |
64 | 66 | $meta->value = $meta_data['value']; |
65 | - if(isset($group)) |
|
66 | - $meta->group = $group; |
|
67 | + if(isset($group)) { |
|
68 | + $meta->group = $group; |
|
69 | + } |
|
67 | 70 | |
68 | 71 | $meta->save(); |
69 | 72 | return $meta; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | */ |
91 | 94 | public function removeMeta($meta_data, $group = null) |
92 | 95 | { |
93 | - if(isset($group)) |
|
94 | - return $this->unsetMeta($meta_data['key_unique'], $group); |
|
96 | + if(isset($group)) { |
|
97 | + return $this->unsetMeta($meta_data['key_unique'], $group); |
|
98 | + } |
|
95 | 99 | |
96 | 100 | return $this->unsetMeta($meta_data['key_unique']); |
97 | 101 | } |