/** * 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]); }
/** * 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); } }
/** * @return Tag */ protected function createTag() : Tag { return Tag::create(['name' => uniqid('Tag', false)]); }
/** * @param int $tagId * * @throws \Exception * * @return bool */ public function deleteById(int $tagId) : bool { return (bool) $this->tagResource->where('id', '=', $tagId)->first()->delete(); }
/** * 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)); }