<?php
namespace App\Controller;
use App\Entity\Auctions;
use App\Entity\MetaData;
use App\Entity\Vehicle;
use App\Entity\VehicleMotusData;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/", name="home_page")
*/
public function index(): Response
{
$repo_auction = $this->getDoctrine()->getRepository(Auctions::class)->findOneBy(['status' => 1]);
$repo_meta = $this->getDoctrine()->getRepository(MetaData::class)
->findOneBy(['id' => 1]);
$featured_vehicles = $this->getDoctrine()->getRepository(VehicleMotusData::class)
->findBy(['isFeatured' => 1]);
$auction_type = $repo_auction->getIsOnline();
$upcoming_auctions = [];
// Physical auction - Monday
if($auction_type == 0){
$upcoming_auctions[] = [
'start' => date('M d, Y 17:00:00', strtotime('next monday')),
'end' => date('M d, Y 17:00:00', strtotime('next tuesday')),
'type' => 'Timed Online Auction',
'id' => 2,
'now' => strtotime(date('Y-m-d H:i:s'))
];
$upcoming_auctions[] = [
'start' => date('M d, Y 11:00:00', strtotime('next monday + 7days')),
'end' => date('M d, Y 13:00:00', strtotime('next monday + 7days')),
'type' => 'Physical Online Auction',
'id' => 3,
'now' => strtotime(date('Y-m-d H:i:s'))
];
// Timed Auction - Tuesday
} else {
$upcoming_auctions[] = [
'start' => date('M d, Y 11:00:00', strtotime('next monday')),
'end' => date('M d, Y 13:00:00', strtotime('next monday')),
'type' => 'Physical Online Auction',
'id' => 2,
'now' => strtotime(date('Y-m-d H:i:s'))
];
$upcoming_auctions[] = [
'start' => date('M d, Y 17:00:00', strtotime('next monday')),
'end' => date('M d, Y 13:00:00', strtotime('next tuesday')),
'type' => 'Timed Online Auction',
'id' => 3,
'now' => strtotime(date('Y-m-d H:i:s'))
];
}
return $this->render('frontend/index.html.twig',
[
'meta' => $repo_meta,
'featured_vehicles' => $featured_vehicles,
'auction' => $repo_auction,
'upcomming_auctions' => $upcoming_auctions,
'now' => strtotime(date('Y-m-d H:i:s'))
]
);
}
/**
* @Route("/404/not-found", name="404_page")
*/
public function notFound(): Response
{
return $this->render('bundles/TwigBundle/Exception/error404.html.twig');
}
}