with($with) ; } // Join with if(is_array($join_with) && count($join_with)) { $records = $records->joinWith($join_with) ; } // Conditions if(is_array($conditions)) { if(count($conditions)) { foreach($conditions as $condition) { $records = $records->andWhere($condition); } } } else { if(strlen($conditions)) { $records = $records->andWhere($conditions); } } // Paramètres if(is_array($params) && count($params)) { foreach($params as $key => $val) { $records = $records->andWhere([$key => $val]); } } if(!isset($params[$pk])) { // Orderby if (isset($orderby) && strlen($orderby)) { $records = $records->orderBy($orderby); } // Limit if (isset($limit) && is_numeric($limit) && $limit > 0) { $records = $records->limit($limit); } } if(isset($params[$pk])) { $record = $records->one(); if($record) { return $record ; } else { throw new NotFoundHttpException( 'Le modèle '.$class.' #'.((int) $params[$pk]).' n\'a pas été trouvé.'); } } else { $records = $records->all(); return $records ; } } }