public function init() { parent::init(); if ($this->source == 'photo') { $this->model = Photo::find()->all(); $this->path = '/upload/multy-thumbs/'; //vd($this->model); } if ($this->source == 'slider') { $this->model = ImageSlider::find()->where(['status' => '0'])->all(); $this->path = '/upload/slider-thumbs/'; } }
public function actionDeletePhoto() { $name = Yii::$app->request->post('name'); $model = Photo::find()->where(['name' => $name])->one(); $model->delete(); }
<?php use yii\helpers\Html; use frontend\assets\AppAsset; use common\models\Photo; /* @var $this \yii\web\View */ /* @var $content string */ AppAsset::register($this); $model = Photo::find()->all(); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "/> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo Html::csrfMetaTags(); ?> <title><?php echo Html::encode($this->title); ?> </title> <?php echo $this->render('parts/_pre_header');