public function createQueryBuilderFromRequest(Request $request)
    {
        $qb = $this->createQueryBuilder('m');

        if ($request->get('ids')) {
            $ids = explode(',', $request->get('ids'));

            $qb->andWhere('m.id IN (:ids)')->setParameter('ids', $ids);
        }
        
        $qb->andWhere('m.status = :status')->setParameter('status', Media::STATUS_ENABLED);

        if ($request->get('search')) {
            $qb->andWhere('m.name LIKE :term')->setParameter('term', '%'.$request->get('search').'%');
        }

        if ($request->get('order')) {
            $direction = ($request->get('orderdir')) ? $request->get('orderdir') : 'asc';
            $qb->orderBy('m.'.$request->get('order'), $direction);
        }

        return $qb;
    }