@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * @var array Guarded fields |
| 45 | 45 | */ |
| 46 | - protected $guarded = ['*']; |
|
| 46 | + protected $guarded = [ '*' ]; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @var array Fillable fields |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public function filterFields($fields) |
| 157 | 157 | { |
| 158 | 158 | $fields->amount_exact->hidden = $this->is_percentage; |
| 159 | - $fields->amount_percentage->hidden = ! $this->is_percentage; |
|
| 159 | + $fields->amount_percentage->hidden = !$this->is_percentage; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $productIds = $this->products()->lists('id'); |
| 170 | 170 | $categories = $this->categories() |
| 171 | - ->with(['products' => function ($product) { |
|
| 171 | + ->with([ 'products' => function($product) { |
|
| 172 | 172 | return $product->select('id'); |
| 173 | - }]) |
|
| 174 | - ->get(['id']); |
|
| 173 | + } ]) |
|
| 174 | + ->get([ 'id' ]); |
|
| 175 | 175 | |
| 176 | 176 | foreach ($categories as $category) { |
| 177 | 177 | foreach ($category->products as $product) { |
| 178 | - $productIds[] = $product->id; |
|
| 178 | + $productIds[ ] = $product->id; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function getAmountExactAttribute() |
| 191 | 191 | { |
| 192 | - return ! $this->is_percentage ? $this->amount : 0; |
|
| 192 | + return !$this->is_percentage ? $this->amount : 0; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function savePrices() |
| 211 | 211 | { |
| 212 | 212 | $id = $this->id; |
| 213 | - Queue::push(function ($job) use ($id) { |
|
| 213 | + Queue::push(function($job) use ($id) { |
|
| 214 | 214 | $discount = Discount::findOrFail($id); |
| 215 | 215 | $productIds = $discount->getAllProductIds(); |
| 216 | 216 | $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get(); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public static function syncAllPrices() |
| 236 | 236 | { |
| 237 | - $data = []; |
|
| 237 | + $data = [ ]; |
|
| 238 | 238 | $discounts = self::isNotExpired()->with('categories.products', 'products')->get(); |
| 239 | 239 | foreach ($discounts as $discount) { |
| 240 | 240 | $products = $discount->products; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | foreach ($products as $product) { |
| 246 | - $data[] = self::buildPriceArray($discount, $product); |
|
| 246 | + $data[ ] = self::buildPriceArray($discount, $product); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | public static function syncProductPrice(Product $product, array $categoryIds) |
| 262 | 262 | { |
| 263 | 263 | $discounts = self::isNotExpired() |
| 264 | - ->whereHas('products', function ($query) use ($product) { |
|
| 264 | + ->whereHas('products', function($query) use ($product) { |
|
| 265 | 265 | return $query->where('id', $product->id); |
| 266 | 266 | }) |
| 267 | - ->orWhereHas('categories', function ($query) use ($categoryIds) { |
|
| 267 | + ->orWhereHas('categories', function($query) use ($categoryIds) { |
|
| 268 | 268 | return $query->whereIn('id', $categoryIds); |
| 269 | 269 | }) |
| 270 | 270 | ->get(); |
| 271 | 271 | |
| 272 | - $data = []; |
|
| 272 | + $data = [ ]; |
|
| 273 | 273 | foreach ($discounts as $discount) { |
| 274 | - $data[] = self::buildPriceArray($discount, $product); |
|
| 274 | + $data[ ] = self::buildPriceArray($discount, $product); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | Price::whereProductId($product->id)->whereNotNull('discount_id')->delete(); |