Beispiel #1
0
 public static function findAllOrdered()
 {
     $sql = "SELECT cm.*, cc.name__pl as category_name FROM core_module cm\n\t\t\tJOIN core_category cc ON cc.id = cm.category_id\n\t\t\tORDER BY cc.`ordering`,  cm.ordering";
     return Module::findBySql($sql)->all();
 }
Beispiel #2
0
 public function beforeValidate()
 {
     $sql = "SELECT * FROM core_module WHERE category_id = :categoryId ORDER BY ordering DESC";
     /** @var Module $module */
     $module = Module::findBySql($sql, [':categoryId' => $this->category_id])->one();
     $maxOrdering = is_null($module) ? 1 : $module->ordering + 1;
     $this->ordering = $maxOrdering + 1;
     return parent::beforeValidate();
     // TODO: Change the autogenerated stub
 }