protected function saveImages($model)
 {
     if (isset($_POST['images'])) {
         foreach ($model->images as $img) {
             if (!array_key_exists($img->id, $_POST['images'])) {
                 $imgDelete = BannersImages::model()->findAllByPk($img->id);
                 foreach ($imgDelete as $item) {
                     $item->delete();
                 }
             }
         }
         $count = count($_POST['images']);
         foreach ($_POST['images'] as $index => $image) {
             $bannerImage = BannersImages::model()->language($_GET)->findByPk($index, 'banner_id = :banner_id', array(':banner_id' => $model->id));
             if ($bannerImage) {
                 $bannerImage->attributes = $image;
                 $bannerImage->sort = $count--;
                 $bannerImage->save();
             } else {
                 $newImage = new BannersImages();
                 $newImage->attributes = $image;
                 $newImage->banner_id = $model->id;
                 $newImage->sort = $count--;
                 $newImage->save();
             }
         }
     }
 }