/**
  * Display the "Christmas Cards" landing page.
  *
  * @return \Illuminate\Contracts\View\View
  */
 public function christmasCardsAction()
 {
     return $this->webUi->view('customer.landing.christmas-cards', ['products' => $this->tagResource->where('name', '=', 'Christmas')->with(['products' => function ($query) {
         /* @var Product $query */
         $query->inStock();
         $query->with(['images', 'options', 'options.images', 'options.stockItems']);
     }])->first()->products]);
 }
Example #2
0
 /**
  * Create a tag and attach to some products.
  *
  * @param string $name
  */
 private function seedTag(string $name = null)
 {
     /** @var Tag $tag */
     $tag = Tag::create(['name' => $name ?? ucfirst($this->faker()->unique()->word)]);
     for ($i = 0, $count = random_int(1, 8); $i < $count; $i++) {
         $product = $this->products()->random();
         if ($tag->products->contains('id', $product->id)) {
             continue;
         }
         $tag->products()->attach($product->id);
         $tag->products->add($product);
     }
 }
Example #3
0
 /**
  * @return Tag
  */
 protected function createTag() : Tag
 {
     return Tag::create(['name' => uniqid('Tag', false)]);
 }
Example #4
0
 /**
  * @param int $tagId
  *
  * @throws \Exception
  *
  * @return bool
  */
 public function deleteById(int $tagId) : bool
 {
     return (bool) $this->tagResource->where('id', '=', $tagId)->first()->delete();
 }
Example #5
0
 /**
  * Should have a presenter class.
  */
 public function testPresenterClass()
 {
     $this->assertTrue(class_exists($this->tag->getPresenterClass()));
 }
 /**
  * Should be able to delete a tag by id.
  */
 public function testDeleteById()
 {
     $this->tagModel->shouldReceive('where->first->delete')->andReturnTrue();
     $this->assertTrue($this->tagRepository->deleteById(5));
 }