<?php
namespace Entrepreneurs\Bundle\AppBundle\Propel;
use Entrepreneurs\Bundle\AppBundle\Propel\Base\DepartementQuery as BaseDepartementQuery;
use Entrepreneurs\Bundle\AppBundle\Propel\Map\DepartementTableMap;
use Propel\Runtime\ActiveQuery\Criteria;
class DepartementQuery extends BaseDepartementQuery
{
/**
* Fix integer values stored as varchar problem with sort.
*/
public function orderByNumero($order = Criteria::ASC)
{
$column = 'CAST('.DepartementTableMap::COL_NUMERO.' AS UNSIGNED)';
if (in_array($order, [Criteria::ASC, strtolower(Criteria::ASC)])) {
return parent::addAscendingOrderByColumn($column);
}
return parent::addDescendingOrderByColumn($column);
}
public function orderByRegionLabel($order = Criteria::ASC)
{
return $this->useRegionQuery()
->orderByLabel($order)
->endUse();
}
public function orderByPoleLabel($order = Criteria::ASC)
{
return $this->usePoleQuery()
->orderByLabel($order)
->endUse();
}
public function orderByCoordinateur($order = Criteria::ASC)
{
return $this->useCoordinateurQuery()
->orderByNom($order)
->orderByPrenom($order)
->endUse();
}
public function orderByDelegue($order = Criteria::ASC)
{
return $this->useDelegueQuery()
->orderByNom($order)
->orderByPrenom($order)
->endUse();
}
public static function createForReferentiel($modelAlias = null, $criteria = null)
{
$query = parent::create($modelAlias, $criteria);
return $query->filterByActif(true)->orderByNumero();
}
public function filterByDemandeInterventionTypes($demandeInterventionTypes = null): self
{
return $this->filterByDemandeInterventionType($demandeInterventionTypes, Criteria::IN);
}
}