예제 #1
0
 /**
  * Deletes an existing Images model.  
  *
  * @param string $url
  *
  * @return mixed
 */
 public function actionDelete($url)
 {
     $model = Images::find()->where(['url' => $url])->one();
     $path = Yii::$app->route->getRouteUpload() . $model->base_name . '.' . $model->extension;
     if (unlink($path)) {
         $model->delete();
     }
     return $this->goHome();
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Images::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'aid' => $this->aid]);
     $query->andFilterWhere(['like', 'cover', $this->cover])->andFilterWhere(['like', 'one', $this->one])->andFilterWhere(['like', 'two', $this->two])->andFilterWhere(['like', 'three', $this->three])->andFilterWhere(['like', 'four', $this->four])->andFilterWhere(['like', 'five', $this->five]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Images::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['image_id' => $this->image_id, 'item_id' => $this->item_id, 'date_added' => $this->date_added, 'date_modified' => $this->date_modified, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'big_image', $this->big_image])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]);
     return $dataProvider;
 }
예제 #4
0
파일: Images.php 프로젝트: dosh93/shop
 static function deleteImages($model)
 {
     $images = Images::find()->where(['product_id' => $model->id])->all();
     $size = sizeof($images);
     $s = $size;
     for ($i = 0; $i <= $s; $i++) {
         if (Yii::$app->request->post('image' . $i)) {
             unlink(Yii::getAlias('@webroot/uploads/image_product/original/' . $images[$i]->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/xm/' . $images[$i]->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/sm/' . $images[$i]->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/lm/' . $images[$i]->url_image));
             $images[$i]->delete();
             $size -= 1;
             $model->images = $size;
             $model->save();
         }
     }
 }
예제 #5
0
파일: Albom.php 프로젝트: kansey/yii2albom
 /**
  * Get the picture is uploaded by user
  *
  * @return mixed 
 */
 public function getImages()
 {
     $listImages = Images::find()->select('url')->where(['tocken' => $this->getTockenUser()])->asArray()->all();
     return $listImages;
 }
예제 #6
0
 public function actionClear()
 {
     foreach (Images::find()->all() as $image) {
         $image->delete();
     }
     Yii::$app->db->createCommand("UPDATE sqlite_sequence SET seq=0 WHERE name='images'")->execute();
     if (Yii::$app->request->isAjax) {
         return true;
     } else {
         $dataProvider = new ActiveDataProvider(['query' => Images::find()]);
         return $this->render('index', ['dataProvider' => $dataProvider]);
     }
 }
예제 #7
0
파일: view.php 프로젝트: dosh93/shop
    echo Html::a("<span class='glyphicon glyphicon-plus'>", ['create'], ['class' => 'btn btn-success', 'data-toggle' => "tooltip", 'data-placement' => "top", 'title' => "Добавить товар"]);
    ?>
                        <?php 
    echo Html::a("<span class='glyphicon glyphicon-list'>", ['orders', 'id' => $model->id], ['class' => 'btn btn-default', 'data-toggle' => "tooltip", 'data-placement' => "top", 'title' => "Посмотреть купленные купоны"]);
    ?>
                    <?php 
}
?>
                </div>

            </div>
            <div style="margin-top: 30px" class="col-md-7">
                <div class="product-image">

                    <?php 
$images = Images::find()->where(['product_id' => $model->id])->all();
$img = [];
$i = 0;
foreach ($images as $image) {
    $img[$i]['content'] = Html::img('@web/uploads/image_product/sm/' . $image->url_image, ['style' => 'height:300px;margin:auto;']);
    $i++;
}
?>
                    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                        <!-- Indicators -->
                        <ol class="carousel-indicators">
                            <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                            <?php 
for ($i = 1; $i < sizeof($images); $i++) {
    ?>
                            <li data-target="#carousel-example-generic" data-slide-to=<?php 
예제 #8
0
 /**
  * 多态关联
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  * A model relation B model  and  A model relation C model
  * demo:ImagesModel  User Goods
  * 从 A model 读取 B OR C 的字段值
  */
 public function morphTo()
 {
     $obj = new Images();
     $rows = $obj->find(1)->relation->toarray();
     print_r($rows);
     return view('index');
 }
예제 #9
0
파일: Product.php 프로젝트: dosh93/shop
 public function sizeImages()
 {
     $this->images = sizeof(Images::find()->where(['product_id' => $this->id])->all());
     $this->save();
 }
예제 #10
0
 /**
  * Lists all Images models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Images::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
예제 #11
0
파일: view.php 프로젝트: dosh93/shop
?>
        <?php 
foreach ($products as $product) {
    ?>
            <div class='col-md-4'>
                <div class='thumbnail view-product' id="product<?php 
    echo $product->id;
    ?>
">
                    <a href=<?php 
    echo Url::to(['product/view', 'id' => $product->id]);
    ?>
>
                        <div class='product-images'>
                            <?php 
    echo Html::img('@web/uploads/image_product/xm/' . \app\models\Images::find()->where(['product_id' => $product->id])->one()->url_image, ['class' => 'product-image']);
    ?>
                        </div>
                        <div class='caption product-name'>
                            <h3 style='text-align: center'><?php 
    echo $product->name;
    ?>
</h3>
                        </div>
                    </a>
                    <div class='row'>
                        <div class='col-md-12'>
                            <h4 class='text-center'>Осталось: <span id="number_of_coupons<?php 
    echo $product->id;
    ?>
"><?php 
예제 #12
0
 public function actionDelete($id)
 {
     if (!Yii::$app->user->can('product/delete')) {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         return $this->redirect('/');
     }
     $images = Images::find()->where(['product_id' => $id])->all();
     $char = Characteristics::find()->where(['product_id' => $id])->all();
     foreach ($char as $c) {
         $c->delete();
     }
     foreach ($images as $image) {
         if (file_exists(Yii::getAlias('@webroot/uploads/image_product/original/' . $image->url_image)) == true) {
             unlink(Yii::getAlias('@webroot/uploads/image_product/original/' . $image->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/xm/' . $image->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/sm/' . $image->url_image));
             unlink(Yii::getAlias('@webroot/uploads/image_product/lm/' . $image->url_image));
         }
         $image->delete();
     }
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
예제 #13
0
파일: _form.php 프로젝트: dosh93/shop
echo $form->field($model, 'description')->widget(CKEditor::className(), ['options' => ['rows' => 6], 'preset' => 'full']);
?>
        </div>
    </div>

        <div class="col-md-12">
            <?php 
echo $form->field($model, 'images[]')->widget(FileInput::classname(), ['showMessage' => false, 'language' => 'ru', 'pluginOptions' => ['showUpload' => false], 'options' => ['accept' => 'image/*', 'multiple' => true]]);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <?php 
if (!$model->isNewRecord && sizeof($images = Images::find()->where(['product_id' => $model->id])->all()) > 0) {
    $i = 0;
    ?>
                <table class="table table-bordered">
                    <caption>Ранее добавленые изображения</caption>
                    <tr>
                        <th>Картинка</th>
                        <th>Удалить</th>
                    </tr>
                    <?php 
    foreach ($images as $image) {
        echo "<tr>";
        echo "<td>";
        echo Html::img('@web/uploads/image_product/xm/' . $image->url_image, ['style' => ' max-height:100px;']);
        echo "</td>";
        echo "<td>";