Skip to content

Instantly share code, notes, and snippets.

@JavierCane
Created November 20, 2016 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JavierCane/683abd35607d30f57cccc69371580a08 to your computer and use it in GitHub Desktop.
Save JavierCane/683abd35607d30f57cccc69371580a08 to your computer and use it in GitHub Desktop.
<?php
namespace AppBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;
final class CourseController extends FOSRestController
{
public function getCourseAction(Request $request)
{
return $this->getDoctrine()
->getEntityManager()
->createQueryBuilder()
->select('c', 'v')
->from('AppBundle\Model\Course', 'c')
->where('c.level', '>', $request->get('from_level', 0))
->getQuery()
->execute();
}
public function getCourseVideosAction($courseId)
{
return $this->getDoctrine()
->getEntityManager()
->createQueryBuilder()
->select('c', 'v')
->from('AppBundle\Model\Course', 'c')
->leftJoin('a.Video', 'v')
->where('c.id', '=', $courseId)
->getQuery()
->execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment