src/Controller/HomeController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Auctions;
  4. use App\Entity\MetaData;
  5. use App\Entity\Vehicle;
  6. use App\Entity\VehicleMotusData;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class HomeController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("/", name="home_page")
  14.      */
  15.     public function index(): Response
  16.     {
  17.         $repo_auction $this->getDoctrine()->getRepository(Auctions::class)->findOneBy(['status' => 1]);
  18.         $repo_meta $this->getDoctrine()->getRepository(MetaData::class)
  19.             ->findOneBy(['id' => 1]);
  20.         $featured_vehicles $this->getDoctrine()->getRepository(VehicleMotusData::class)
  21.             ->findBy(['isFeatured' => 1]);
  22.         $auction_type $repo_auction->getIsOnline();
  23.         $upcoming_auctions = [];
  24.         // Physical auction - Monday
  25.         if($auction_type == 0){
  26.             $upcoming_auctions[] = [
  27.                 'start' => date('M d, Y 17:00:00'strtotime('next monday')),
  28.                 'end' => date('M d, Y 17:00:00'strtotime('next tuesday')),
  29.                 'type' => 'Timed Online Auction',
  30.                 'id' => 2,
  31.                 'now' => strtotime(date('Y-m-d H:i:s'))
  32.             ];
  33.             $upcoming_auctions[] = [
  34.                 'start' => date('M d, Y 11:00:00'strtotime('next monday + 7days')),
  35.                 'end' => date('M d, Y 13:00:00'strtotime('next monday + 7days')),
  36.                 'type' => 'Physical Online Auction',
  37.                 'id' => 3,
  38.                 'now' => strtotime(date('Y-m-d H:i:s'))
  39.             ];
  40.         // Timed Auction - Tuesday
  41.         } else {
  42.             $upcoming_auctions[] = [
  43.                 'start' => date('M d, Y 11:00:00'strtotime('next monday')),
  44.                 'end' => date('M d, Y 13:00:00'strtotime('next monday')),
  45.                 'type' => 'Physical Online Auction',
  46.                 'id' => 2,
  47.                 'now' => strtotime(date('Y-m-d H:i:s'))
  48.             ];
  49.             $upcoming_auctions[] = [
  50.                 'start' => date('M d, Y 17:00:00'strtotime('next monday')),
  51.                 'end' => date('M d, Y 13:00:00'strtotime('next tuesday')),
  52.                 'type' => 'Timed Online Auction',
  53.                 'id' => 3,
  54.                 'now' => strtotime(date('Y-m-d H:i:s'))
  55.             ];
  56.         }
  57.         return $this->render('frontend/index.html.twig',
  58.             [
  59.                 'meta' => $repo_meta,
  60.                 'featured_vehicles' => $featured_vehicles,
  61.                 'auction' => $repo_auction,
  62.                 'upcomming_auctions' => $upcoming_auctions,
  63.                 'now' => strtotime(date('Y-m-d H:i:s'))
  64.             ]
  65.         );
  66.     }
  67.     /**
  68.      * @Route("/404/not-found", name="404_page")
  69.      */
  70.     public function notFound(): Response
  71.     {
  72.         return $this->render('bundles/TwigBundle/Exception/error404.html.twig');
  73.     }
  74. }