コード例 #1
0
 /**
  * Query against all fields
  * @param       []                      $query              Values to query against
  * @param       bool                    $ignorePagination   If true will not return pagination
  * @param       int                     $maxLimit           If provided limit is greater than this value, set is to this value
  * @param       int                     $maxPage            If the provided page is greater than this value, restrict it to this value
  * @return      Country[]|\Illuminate\Pagination\LengthAwarePaginator
  */
 function where($query, $ignorePagination = true, $maxLimit = 5000, $maxPage = 100)
 {
     $pagination = $this->buildPagination($query, $maxLimit, $maxPage);
     $qb = $this->_em->createQueryBuilder();
     $qb->from('postage\\Models\\Country', 'country')->leftJoin('country.continent', 'continent', Query\Expr\Join::ON)->innerJoin('country.subdivisions', 'subdivision', Query\Expr\Join::ON);
     if (!is_null(ArrayUtil::get($query['countryIds']))) {
         $qb->andWhere($qb->expr()->in('country.id', $query['countryIds']));
     }
     if (!is_null(ArrayUtil::get($query['continentIds']))) {
         $qb->andWhere($qb->expr()->in('continent.id', $query['continentIds']));
     }
     if (!is_null(ArrayUtil::get($query['subdivisionIds']))) {
         $qb->andWhere($qb->expr()->in('subdivision.id', $query['subdivisionIds']));
     }
     if (!is_null(ArrayUtil::get($query['isEU']))) {
         $qb->andWhere('country.isEU                 =               :isEU')->setParameter('isEU', $query['isEU']);
     }
     if (!is_null(ArrayUtil::get($query['isUK']))) {
         $qb->andWhere('country.isUK                 =               :isUK')->setParameter('isUK', $query['isUK']);
     }
     if (!is_null(ArrayUtil::get($query['isUSTerritory']))) {
         $qb->andWhere('country.isUSTerritory        =              :isUSTerritory')->setParameter('isUSTerritory', $query['isUSTerritory']);
     }
     $qb->orderBy('country.id', 'ASC');
     if ($ignorePagination) {
         return $qb->getQuery()->getResult();
     } else {
         return $this->paginate($qb->getQuery(), $pagination['limit']);
     }
 }
コード例 #2
0
 public function __construct($data = null)
 {
     $this->id = NULL;
     $this->statusId = 1;
     $this->countries = new ArrayCollection();
     if (is_array($data)) {
         $this->name = ArrayUtil::get($data['name']);
         $this->symbol = ArrayUtil::get($data['symbol']);
         $this->expiresAt = ArrayUtil::get($data['expiresAt']);
     }
 }
コード例 #3
0
 public function __construct($data = null)
 {
     $this->id = NULL;
     $this->statusId = 1;
     $this->createdAt = new \DateTime();
     $this->expiresAt = new \DateTime('2038-01-01 01:01:01');
     if (is_array($data)) {
         $this->fromDistanceType = ArrayUtil::get($data['fromDistanceType'], '');
         $this->toDistanceType = ArrayUtil::get($data['toDistanceType'], '');
     }
 }
コード例 #4
0
 public function __construct($data = null)
 {
     $this->id = NULL;
     $this->statusId = 1;
     $this->createdAt = new \DateTime();
     $this->expiresAt = new \DateTime('2038-01-01 01:01:01');
     if (is_array($data)) {
         $this->name = ArrayUtil::get($data['name'], '');
         $this->symbol = ArrayUtil::get($data['symbol'], '');
     }
 }
コード例 #5
0
 function where($params)
 {
     $qb = $this->_em->createQueryBuilder();
     if (ArrayUtil::get($params['selector'], NULL)) {
         $qb->select(['subdivisionTypes.id, subdivisionTypes.name']);
     } else {
         $qb->select(['subdivisionTypes']);
     }
     $qb->from('app\\Models\\Geography\\SubdivisionType', 'subdivisionTypes');
     // Order by
     if (is_null(ArrayUtil::get($params['orderBy'], NULL))) {
         $qb->orderBy('subdivisionTypes.id', 'ASC');
     }
     return $qb->getQuery()->getResult();
 }
 /**
  * Query against all fields
  * @param       []                      $query              Values to query against
  * @param       bool                    $ignorePagination   If true will not return pagination
  * @param       int|null                $maxLimit           If provided limit is greater than this value, set is to this value
  * @param       int|null                $maxPage            If the provided page is greater than this value, restrict it to this value
  * @return      DistanceConversion[]|\Illuminate\Pagination\LengthAwarePaginator
  */
 function where($query, $ignorePagination = true, $maxLimit = 5000, $maxPage = 100)
 {
     $pagination = $this->buildPagination($query, $maxLimit, $maxPage);
     $qb = $this->_em->createQueryBuilder();
     $qb->select(['distanceConversion']);
     $qb->from('app\\Models\\DistanceConversion', 'distanceConversion')->innerJoin('distanceConversion.fromDistanceType', 'fromDistanceType', Query\Expr\Join::ON)->innerJoin('distanceConversion.toDistanceType', 'toDistanceType', Query\Expr\Join::ON);
     if (!is_null(ArrayUtil::get($query['fromDistanceTypeIds']))) {
         $qb->andWhere($qb->expr()->in('fromDistanceType.id', $query['fromDistanceTypeIds']));
     }
     if (!is_null(ArrayUtil::get($query['toDistanceTypeIds']))) {
         $qb->andWhere($qb->expr()->in('toDistanceType.id', $query['toDistanceTypeIds']));
     }
     $qb->orderBy('distanceConversion.id', 'ASC');
     if ($ignorePagination) {
         return $qb->getQuery()->getResult();
     } else {
         return $this->paginate($qb->getQuery(), $pagination['limit']);
     }
 }
コード例 #7
0
 /**
  * Query against all fields
  * @param       []                      $query              Values to query against
  * @param       bool                    $ignorePagination   If true will not return pagination
  * @param       int                     $maxLimit           If provided limit is greater than this value, set is to this value
  * @param       int                     $maxPage            If the provided page is greater than this value, restrict it to this value
  * @return      Continent[]|\Illuminate\Pagination\LengthAwarePaginator
  */
 function where($query, $ignorePagination = true, $maxLimit = 5000, $maxPage = 100)
 {
     $pagination = parent::buildPagination($query, $maxLimit, $maxPage);
     $qb = $this->_em->createQueryBuilder();
     $qb->from('postage\\Models\\Continent', 'continent');
     if (!is_null(ArrayUtil::get($query['continentIds']))) {
         $qb->andWhere($qb->expr()->in('continent.id', $query['continentIds']));
     }
     if (!is_null(ArrayUtil::get($query['countryIds']))) {
         $qb->leftJoin('continent.countries', 'country', Query\Expr\Join::ON);
         $qb->andWhere($qb->expr()->in('country.id', $query['countryIds']));
     }
     $qb->orderBy('continent.id', 'ASC');
     $qb->select(['continent']);
     if ($ignorePagination) {
         return $qb->getQuery()->getResult();
     } else {
         return $this->paginate($qb->getQuery(), $pagination['limit']);
     }
 }
コード例 #8
0
 /**
  * Build attributes used for pagination
  * @param       []                      $data               Information used to construct
  * @param       int                     $maxLimit           If provided limit is greater than this value, set is to this value
  * @param       int                     $maxPage            If the provided page is greater than this value, restrict it to this value
  * @return      array                   $data               Everything needed for pagination
  */
 protected function buildPagination($data = null, $maxLimit = 5000, $maxPage = 100)
 {
     $data = is_array($data) ? $data : [];
     if (is_array($data)) {
         $data['page'] = ArrayUtil::get($data['page'], 1);
         $data['limit'] = ArrayUtil::get($data['limit'], 80);
     }
     // page checks
     if (StringUtil::isEmptyOrNull($data['page']) || !NumberUtil::isPositiveInt($data['page'])) {
         $data['page'] = 1;
     }
     if ($data['page'] > $maxPage) {
         $data['page'] = $maxPage;
     }
     // limit checks
     if (StringUtil::isEmptyOrNull($data['limit']) || !NumberUtil::isPositiveInt($data['limit'])) {
         $data['limit'] = 80;
     }
     if ($data['limit'] > $maxLimit) {
         $data['limit'] = $maxLimit;
     }
     return $data;
 }
コード例 #9
0
 public function __construct($data = null)
 {
     $this->id = NULL;
     $this->statusId = 1;
     $this->createdAt = new \DateTime();
     $this->expiresAt = new \DateTime('2038-01-01 01:01:01');
     $this->subdivisions = new ArrayCollection();
     $this->postalDistricts = new ArrayCollection();
     $this->restrictedPostalCodeCharacters = new ArrayCollection();
     $this->supportedPostalCodeCharacters = new ArrayCollection();
     if (is_array($data)) {
         $this->name = ArrayUtil::get($data['name']);
         $this->iso2 = ArrayUtil::get($data['iso2']);
         $this->iso3 = ArrayUtil::get($data['iso3']);
         $this->isoNumeric = ArrayUtil::get($data['isoNumeric']);
         $this->fipsCode = ArrayUtil::get($data['fipsCode']);
         $this->capital = ArrayUtil::get($data['capital']);
         $this->continent = ArrayUtil::get($data['continent']);
         $this->isEU = ArrayUtil::get($data['isEU']);
         $this->isUK = ArrayUtil::get($data['isUK']);
         $this->isUSTerritory = ArrayUtil::get($data['isUSTerritory']);
     }
 }
コード例 #10
0
 public function __construct($data = null)
 {
     $this->id = NULL;
     $this->statusId = 1;
     if (is_array($data)) {
         $this->name = ArrayUtil::get($data['name']);
         $this->company = ArrayUtil::get($data['company']);
         $this->street1 = ArrayUtil::get($data['street1']);
         $this->street2 = ArrayUtil::get($data['street2']);
         $this->city = ArrayUtil::get($data['city']);
         $this->stateProvince = ArrayUtil::get($data['stateProvince']);
         $this->postalCode = ArrayUtil::get($data['postalCode']);
         $this->subdivision = ArrayUtil::get($data['subdivision']);
         $this->country = ArrayUtil::get($data['country']);
         $this->phone = ArrayUtil::get($data['phone']);
         $this->email = ArrayUtil::get($data['email']);
     }
 }