Skip to content

Instantly share code, notes, and snippets.

@JKetelaar
Created April 16, 2018 20:05
Show Gist options
  • Save JKetelaar/f8af6a4850b915dc62adefec77ab17ac to your computer and use it in GitHub Desktop.
Save JKetelaar/f8af6a4850b915dc62adefec77ab17ac to your computer and use it in GitHub Desktop.
/**
* Displays User Dashboard
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*
* @Route("/")
*/
public function indexAction(Request $request)
{
$user = $this->get('user_service')->getUser();
if ($user->isDentist()) {
$appointments = $this->get('user_service')->getUser()->getDentistAppointments();
} else {
if ($user->isHygienist()) {
$appointments = $this->get('user_service')->getUser()->getHygienistAppointments();
} else {
$appointments = $this->get('user_service')->getUser()->getAppointments();
}
}
$manager = $this->getDoctrine()->getEntityManager();
foreach($appointments as $appointment){
$manager->remove($appointment);
}
$manager->flush();
//TODO: Add Upcoming Appointments Notification [Within 7 Days of Today]
return $this->render(
'@App/dashboard.html.twig',
['appointments' => $appointments, 'user' => $user]
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment