diff --git a/composer.json b/composer.json index 8959f173..ecf52e0b 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "symfony/validator": "5.2.*", "symfony/yaml": "5.2.*", "twig/extra-bundle": "^2.12|^3.0", + "twig/intl-extra": "^3.2", "twig/twig": "^2.12|^3.0" }, "config": { diff --git a/composer.lock b/composer.lock index 176f1ff0..ee5b9c00 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d649636616e422448c4e513839051da1", + "content-hash": "090a14a8ae8f011875dd03f11f7adb96", "packages": [ { "name": "composer/package-versions-deprecated", @@ -5980,6 +5980,75 @@ ], "time": "2021-01-05T15:24:51+00:00" }, + { + "name": "twig/intl-extra", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/intl-extra.git", + "reference": "919e8f945c30bd3efeb6a4d79722cda538116658" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/intl-extra/zipball/919e8f945c30bd3efeb6a4d79722cda538116658", + "reference": "919e8f945c30bd3efeb6a4d79722cda538116658", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/intl": "^4.3|^5.0", + "twig/twig": "^2.4|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4.9|^5.0.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\Extra\\Intl\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for Intl", + "homepage": "https://twig.symfony.com", + "keywords": [ + "intl", + "twig" + ], + "support": { + "source": "https://github.com/twigphp/intl-extra/tree/v3.2.1" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2021-01-01T14:58:18+00:00" + }, { "name": "twig/twig", "version": "v3.2.1", diff --git a/public/styles/app.css b/public/styles/app.css index 69b863a9..66c3ee6b 100644 --- a/public/styles/app.css +++ b/public/styles/app.css @@ -8,10 +8,14 @@ a, a:hover { color: #000; } +h1 { + font-size: 1.7rem; +} + .header { background-color: #343a40; margin-bottom: 30px; - border-bottom: 2px solid #efefee; + border-bottom: 2px solid #BA1414; padding: 0; } @@ -46,13 +50,30 @@ a, a:hover { border: 1px solid #efefee; box-shadow: 0 0 7px 4px #efefee; border-radius: 5px; - margin-top: 25px; - padding: 20px; - display: flex; - flex-direction: column; +} + +.component-light ul li a:hover { + background: #add8e6; +} +.component-light ul li a.selected { + background: #efefee; } .aside-collapsed { padding: 0 15px; } +/** + * Products + */ +.product-image img { + width: 100%; + height: auto; + border-top-left-radius: 5px; + border-top-right-radius: 5px; +} + +.product-image h3 { + font-size: 1.2rem; +} + diff --git a/public/uploads/products/blank-cds.png b/public/uploads/products/blank-cds.png new file mode 100644 index 00000000..faac845f Binary files /dev/null and b/public/uploads/products/blank-cds.png differ diff --git a/public/uploads/products/dog-lamp.png b/public/uploads/products/dog-lamp.png new file mode 100644 index 00000000..b27d7a1d Binary files /dev/null and b/public/uploads/products/dog-lamp.png differ diff --git a/public/uploads/products/floppy-disc.png b/public/uploads/products/floppy-disc.png new file mode 100644 index 00000000..1efcc66b Binary files /dev/null and b/public/uploads/products/floppy-disc.png differ diff --git a/public/uploads/products/hammock.png b/public/uploads/products/hammock.png new file mode 100644 index 00000000..e87441f6 Binary files /dev/null and b/public/uploads/products/hammock.png differ diff --git a/public/uploads/products/indoor-plant.png b/public/uploads/products/indoor-plant.png new file mode 100644 index 00000000..dd2c3e4c Binary files /dev/null and b/public/uploads/products/indoor-plant.png differ diff --git a/public/uploads/products/inflatable-sofa.png b/public/uploads/products/inflatable-sofa.png new file mode 100644 index 00000000..6e4e58fb Binary files /dev/null and b/public/uploads/products/inflatable-sofa.png differ diff --git a/public/uploads/products/papers.png b/public/uploads/products/papers.png new file mode 100644 index 00000000..a4a242df Binary files /dev/null and b/public/uploads/products/papers.png differ diff --git a/public/uploads/products/pen.png b/public/uploads/products/pen.png new file mode 100644 index 00000000..4f056dca Binary files /dev/null and b/public/uploads/products/pen.png differ diff --git a/public/uploads/products/popcorn.png b/public/uploads/products/popcorn.png new file mode 100644 index 00000000..6c6dee0c Binary files /dev/null and b/public/uploads/products/popcorn.png differ diff --git a/public/uploads/products/puzzle.png b/public/uploads/products/puzzle.png new file mode 100644 index 00000000..912dcbc0 Binary files /dev/null and b/public/uploads/products/puzzle.png differ diff --git a/public/uploads/products/spigot.png b/public/uploads/products/spigot.png new file mode 100644 index 00000000..b23c07cc Binary files /dev/null and b/public/uploads/products/spigot.png differ diff --git a/public/uploads/products/velvis.png b/public/uploads/products/velvis.png new file mode 100644 index 00000000..ad563d28 Binary files /dev/null and b/public/uploads/products/velvis.png differ diff --git a/src/Controller/ProductController.php b/src/Controller/ProductController.php index bca421b7..78fc1785 100644 --- a/src/Controller/ProductController.php +++ b/src/Controller/ProductController.php @@ -5,6 +5,7 @@ use App\Entity\Category; use App\Entity\Product; use App\Repository\CategoryRepository; +use App\Repository\ProductRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Response; @@ -14,10 +15,11 @@ class ProductController extends AbstractController /** * @Route("/", name="app_homepage") */ - public function index(CategoryRepository $categoryRepository): Response + public function index(CategoryRepository $categoryRepository, ProductRepository $productRepository): Response { return $this->render('product/index.html.twig', [ 'categories' => $categoryRepository->findAll(), + 'products' => $productRepository->findAllMostPopular(), ]); } diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index c34bb709..83bad634 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -19,32 +19,16 @@ public function __construct(ManagerRegistry $registry) parent::__construct($registry, Product::class); } - // /** - // * @return Product[] Returns an array of Product objects - // */ - /* - public function findByExampleField($value) + /** + * Fake "most popular" method + * + * @return Product[] + */ + public function findAllMostPopular() { - return $this->createQueryBuilder('p') - ->andWhere('p.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('p.id', 'ASC') - ->setMaxResults(10) + return $this->createQueryBuilder('product') + ->setMaxResults(15) ->getQuery() - ->getResult() - ; + ->execute(); } - */ - - /* - public function findOneBySomeField($value): ?Product - { - return $this->createQueryBuilder('p') - ->andWhere('p.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ } diff --git a/symfony.lock b/symfony.lock index 089b0b8a..86a0c0bd 100644 --- a/symfony.lock +++ b/symfony.lock @@ -420,6 +420,9 @@ "twig/extra-bundle": { "version": "v3.2.1" }, + "twig/intl-extra": { + "version": "v3.2.1" + }, "twig/twig": { "version": "v3.2.1" } diff --git a/templates/product/index.html.twig b/templates/product/index.html.twig index 219a9863..ab373265 100644 --- a/templates/product/index.html.twig +++ b/templates/product/index.html.twig @@ -1,5 +1,103 @@ {% extends 'base.html.twig' %} {% block body %} -
+
+
+ + +
+ +
+
+

+ All Products +

+
+
+
+ +
+
+
+
+ {% for product in products %} +
+
+ +
+

+ {{ product.price|format_currency('USD') }}

+ +
+
+
+
brought to you by Rest + at Work
+
+ {% else %} +
+
+ Whoopsie Daisy, no products found! +
+
+ {% endfor %} +
+ +
+ + Shipping takes 10-13 weeks, and products probably won't work + +
+
+
+
{% endblock %}