Commit 5e9445d2aa360c3619f735509807c9f21f771b4e
1 parent
4d5dbae3
big commti
Showing
3 changed files
with
10 additions
and
5 deletions
Show diff stats
common/modules/product/controllers/ManageController.php
@@ -88,6 +88,9 @@ class ManageController extends Controller | @@ -88,6 +88,9 @@ class ManageController extends Controller | ||
88 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 88 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
89 | 89 | ||
90 | if ($model->save() && $model->imagesUpload) { | 90 | if ($model->save() && $model->imagesUpload) { |
91 | + | ||
92 | + $imgDir = Yii::getAlias('@storage/articles/'); | ||
93 | + | ||
91 | if ( ($images = $model->imagesUpload()) !== FALSE) { | 94 | if ( ($images = $model->imagesUpload()) !== FALSE) { |
92 | foreach ($images as $image) { | 95 | foreach ($images as $image) { |
93 | $imageModel = new ProductImage(); | 96 | $imageModel = new ProductImage(); |
common/modules/product/models/Product.php
@@ -41,7 +41,7 @@ class Product extends \yii\db\ActiveRecord | @@ -41,7 +41,7 @@ class Product extends \yii\db\ActiveRecord | ||
41 | public $_variants = []; | 41 | public $_variants = []; |
42 | 42 | ||
43 | /** @var array $_images */ | 43 | /** @var array $_images */ |
44 | - public $imagesUpload = []; | 44 | + public $imagesUpload = ''; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * @inheritdoc | 47 | * @inheritdoc |
@@ -366,8 +366,13 @@ class Product extends \yii\db\ActiveRecord | @@ -366,8 +366,13 @@ class Product extends \yii\db\ActiveRecord | ||
366 | $i++; | 366 | $i++; |
367 | $imageName = $image->baseName .'_'. $i .'.'. $image->extension; | 367 | $imageName = $image->baseName .'_'. $i .'.'. $image->extension; |
368 | } | 368 | } |
369 | + $imgDir =Yii::getAlias('@imagesDir/products/'); | ||
370 | + if(!is_dir($imgDir)) { | ||
371 | + mkdir($imgDir, 0755, true); | ||
372 | + } | ||
373 | + | ||
369 | 374 | ||
370 | - $image->saveAs(Yii::getAlias('@imagesDir/products/' .$imageName)); | 375 | + $image->saveAs($imgDir .$imageName); |
371 | $images[] = $imageName; | 376 | $images[] = $imageName; |
372 | } | 377 | } |
373 | return $images; | 378 | return $images; |
common/modules/product/views/manage/_form.php
@@ -5,9 +5,6 @@ use yii\widgets\ActiveForm; | @@ -5,9 +5,6 @@ use yii\widgets\ActiveForm; | ||
5 | use yii\helpers\ArrayHelper; | 5 | use yii\helpers\ArrayHelper; |
6 | use common\components\artboxtree\ArtboxTreeHelper; | 6 | use common\components\artboxtree\ArtboxTreeHelper; |
7 | use common\modules\product\helpers\ProductHelper; | 7 | use common\modules\product\helpers\ProductHelper; |
8 | -use kartik\file\FileInput; | ||
9 | -use unclead\widgets\MultipleInput; | ||
10 | -use unclead\widgets\MultipleInputColumn; | ||
11 | use kartik\select2\Select2; | 8 | use kartik\select2\Select2; |
12 | 9 | ||
13 | /* @var $this yii\web\View */ | 10 | /* @var $this yii\web\View */ |