public function search($params)
 {
     $query = Division::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Lists all Division models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Division::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Example #3
0
 public static function getMap()
 {
     return ArrayHelper::map(Division::find()->where(['active' => 1])->orderBy('ord')->asArray()->all(), 'id', 'name');
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return mixed
  */
 public function destroy($id)
 {
     $canBeDeleted = empty(Division::find($id)->fixtures->toArray());
     if ($canBeDeleted) {
         Division::destroy($id);
         \Flash::success('Division deleted!');
     } else {
         \Flash::error('Cannot delete because they are existing fixtures in this division.');
     }
     return redirect('admin/data-management/divisions');
 }