コード例 #1
0
ファイル: AController.php プロジェクト: nanodesu88/easyii
 public function actionItemremove()
 {
     $itemId = Yii::$app->request->post('item_id');
     $name = Yii::$app->request->post('name');
     $model = CarouselCatalog::find()->where(['name' => $name])->one();
     if ($model) {
         $items = $model->items;
         if (in_array($itemId, $items)) {
             $key = array_search($itemId, $items);
             if (is_numeric($key)) {
                 unset($items[$key]);
             }
         }
         $model->items = array_values($items);
         $model->save();
     }
 }