Example #1
0
 /**
  * Load the list scoreboard data
  *
  * @return void
  */
 public function loadScoreboard()
 {
     $products = Product::isEnabled()->count();
     $discounted = Product::discounted()->isEnabled()->count();
     $meter = $products > 0 ? round($discounted / $products * 100) : 0;
     $this->vars['scoreboard'] = ['products' => $products, 'discounted' => $discounted, 'meter' => $meter];
 }
Example #2
0
 /**
  * Load the list scoreboard data
  *
  * @return void
  */
 public function loadScoreboard()
 {
     $total = Product::count();
     $enabled = Product::isEnabled()->count();
     $inStock = Product::inStock()->isEnabled()->count();
     $outOfStock = Product::outOfStock()->isEnabled()->count();
     $discounted = Product::discounted()->isEnabled()->count();
     $averagePrice = Product::joinPrice()->isEnabled()->avg('price');
     $disabled = $total - $enabled;
     $this->vars['scoreboard'] = ['total' => $total, 'enabled' => $enabled, 'disabled' => $disabled, 'inStock' => $inStock, 'outOfStock' => $outOfStock, 'averagePrice' => CurrencySettings::format($averagePrice)];
 }
 public function test_is_enabled_scope()
 {
     $foo = Factory::create(new Product(), ['is_enabled' => true]);
     $bar = Factory::create(new Product(), ['is_enabled' => false]);
     $is_enabled = Product::isEnabled()->get();
     $this->assertEquals(1, $is_enabled->count());
     $this->assertEquals($foo->id, $is_enabled->first()->id);
 }