diff --git a/backend/controllers/LogoController.php b/backend/controllers/LogoController.php new file mode 100644 index 0000000..545b83f --- /dev/null +++ b/backend/controllers/LogoController.php @@ -0,0 +1,135 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + 'access' => [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + public function actions() + { + return [ + 'index' => [ + 'class' => Index::className(), + 'columns' => [ + 'link' => [ + 'type' => Index::ACTION_COL, + ], + 'sort' => [ + 'type' => Index::POSITION_COL, + ], + ], + 'model' => Logo::className(), + 'hasLanguage' => false, + 'enableMassDelete' => true, + 'modelPrimaryKey' => 'id', + ], + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), + 'view' => [ + 'class' => View::className(), + 'model' => Logo::className(), + 'hasAlias' => true, + 'hasGallery' => true, + 'fields' => [ + [ + 'name' => 'image_id', + 'type' => Form::IMAGE, + ], + ], + ], + 'delete' => [ + 'class' => Delete::className(), + ], + ]; + } + + public function findModel($id) + { + $model = Logo::find() + ->where([ 'id' => $id ]) + ->one(); + if ($model !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + public function newModel() + { + return new Logo(); + } + + public function deleteModel($id) + { + $page = Logo::find() + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + + return $page->delete(); + } + + protected static function fieldsConfig() + { + return [ + 'model' => Logo::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + ], + 'fields' => [ + + [ + 'name' => 'image_id', + 'type' => Form::IMAGE, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + ], + ]; + } + } \ No newline at end of file diff --git a/backend/views/layouts/menu_items.php b/backend/views/layouts/menu_items.php index 2d4df2a..8684099 100755 --- a/backend/views/layouts/menu_items.php +++ b/backend/views/layouts/menu_items.php @@ -48,6 +48,10 @@ 'label' => \Yii::t('app', 'Speakers'), 'url' => [ '/speaker/index' ], ], + [ + 'label' => \Yii::t('app', 'Logo'), + 'url' => [ '/logo/index' ], + ], ], ], // [ diff --git a/common/models/Logo.php b/common/models/Logo.php new file mode 100644 index 0000000..04197fe --- /dev/null +++ b/common/models/Logo.php @@ -0,0 +1,49 @@ + null], + [['image_id', 'sort'], 'integer'], + [['link'], 'string'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'image_id' => Yii::t('app', 'Image ID'), + 'link' => Yii::t('app', 'Link'), + 'sort' => Yii::t('app', 'Sort'), + ]; + } +} diff --git a/console/migrations/m180912_134138_create_logo_table.php b/console/migrations/m180912_134138_create_logo_table.php new file mode 100644 index 0000000..1e7d568 --- /dev/null +++ b/console/migrations/m180912_134138_create_logo_table.php @@ -0,0 +1,30 @@ +createTable('logo', [ + 'id' => $this->primaryKey(), + 'image_id' => $this->integer(), + 'link' => $this->text(), + 'sort' => $this->integer() + ]); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable('logo'); + } +} -- libgit2 0.21.4