<?php
/**
* Created by PhpStorm.
* User: laurentiu
* Date: 21.09.2017
* Time: 20:40
*/
namespace ClientBundle\Controller;
use AdminBundle\Controller\BaseController;
use AdminBundle\Entity\User;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class DashboardController extends BaseController
{
public function bounceAction() {
$route = 'client_login';
if ($user = $this->getUser()) {
if (
$user->hasRole('ROLE_CLIENT') ||
$user->hasRole('ROLE_COMPANY')
) {
$route = 'client_bookings';
}
}
return $this->redirectToRoute($route);
}
public function indexAction()
{
return $this->render('@Client/dashboard.html.twig');
}
public function companyIndexAction()
{
return $this->render('@Client/company/dashboard.html.twig');
}
public function profileAction()
{
/** @var User $user */
$user = $this->getUser();
if (!$user || !$user->hasRole('ROLE_CLIENT') || !($user instanceof User)) {
throw new NotFoundHttpException('Access Denied!');
}
return $this->render('@Client/profile.html.twig', [
'client' => $user,
]);
}
public function companyProfileAction()
{
/** @var User $user */
$user = $this->getUser();
if (!$user || !$user->hasRole('ROLE_COMPANY') || !($user instanceof User)) {
throw new NotFoundHttpException('Access Denied!');
}
return $this->render('@Client/company/profile.html.twig', [
'client' => $user,
]);
}
}