Completed
Push — master ( 9d856e...0c0853 )
by Scott
03:28
created
models/Discount.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,9 +168,9 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $categoryProductIds = $this->categories()
170 170
             ->select('id')
171
-            ->with(['products' => function ($products) {
171
+            ->with([ 'products' => function($products) {
172 172
                 return $products->select('id');
173
-            }])
173
+            } ])
174 174
             ->lists('categories.products.id');
175 175
 
176 176
         $productIds = $this->products()->lists('id');
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function getAmountExactAttribute()
187 187
     {
188
-        return ! $this->is_percentage ? $this->amount : 0;
188
+        return !$this->is_percentage ? $this->amount : 0;
189 189
     }
190 190
 
191 191
     /**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function savePrices()
207 207
     {
208 208
         $id = $this->id;
209
-        Queue::push(function ($job) use ($id) {
209
+        Queue::push(function($job) use ($id) {
210 210
             $discount = Discount::findOrFail($id);
211 211
             $productIds = $discount->getAllProductIds();
212 212
             $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get();
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public static function syncAllPrices()
238 238
     {
239
-        $data = [];
239
+        $data = [ ];
240 240
         $discounts = self::isNotExpired()->with('categories.products', 'products')->get();
241 241
         foreach ($discounts as $discount) {
242 242
             $products = $discount->products;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             }
246 246
 
247 247
             foreach ($products as $product) {
248
-                $data[] = [
248
+                $data[ ] = [
249 249
                     'discount_id' => $discount->id,
250 250
                     'end_at' => $discount->end_at,
251 251
                     'price' => $discount->calculatePrice($product->base_price),
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
     public static function syncProductPrice(Product $product, array $categoryIds)
263 263
     {
264 264
         $discounts = self::isNotExpired()
265
-            ->whereHas('products', function ($query) use ($product) {
265
+            ->whereHas('products', function($query) use ($product) {
266 266
                 return $query->where('id', $product->id);
267 267
             })
268
-            ->orWhereHas('categories', function ($query) use ($categoryIds) {
268
+            ->orWhereHas('categories', function($query) use ($categoryIds) {
269 269
                 return $query->whereIn('id', $categoryIds);
270 270
             })
271 271
             ->get();
272 272
 
273
-        $data = [];
273
+        $data = [ ];
274 274
         foreach ($discounts as $discount) {
275
-            $data[] = [
275
+            $data[ ] = [
276 276
                 'discount_id' => $discount->id,
277 277
                 'end_at' => $discount->end_at,
278 278
                 'price' => $discount->calculatePrice($product->base_price),
Please login to merge, or discard this patch.