diff --git a/backend/controllers/PartnerController.php b/backend/controllers/PartnerController.php new file mode 100644 index 0000000..200b3f5 --- /dev/null +++ b/backend/controllers/PartnerController.php @@ -0,0 +1,143 @@ + [ + '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, + ], + 'status' => [ + 'type' => Index::STATUS_COL, + ], + ], + 'model' => Partner::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' => Partner::className(), + 'hasAlias' => false, + 'fields' => [ + [ + 'name' => 'image_id', + 'type' => Form::IMAGE, + ], + [ + 'name' => 'link', + 'type' => Form::STRING, + ], + ], + ], + 'delete' => [ + 'class' => Delete::className(), + ], + ]; + } + public function findModel($id) + { + $model = Partner::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 Partner(); + } + + public function deleteModel($id) + { + $page = Partner::find() + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + return $page->delete(); + } + + protected static function fieldsConfig() + { + return [ + 'model' => Partner::className(), + 'hasAlias' => false, + 'fields' => [ + + [ + 'name' => 'image_id', + 'type' => Form::IMAGE, + ], + [ + 'name' => 'link', + 'type' => Form::STRING, + ], + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + '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 12440ea..82b584d 100755 --- a/backend/views/layouts/menu_items.php +++ b/backend/views/layouts/menu_items.php @@ -50,6 +50,11 @@ 'url' => [ '/gallery/index' ], ], + [ + 'label' => \Yii::t('core', 'Partner'), + 'url' => [ '/partner/index' ], + + ], ], ], diff --git a/common/models/Partner.php b/common/models/Partner.php new file mode 100644 index 0000000..b4ed42f --- /dev/null +++ b/common/models/Partner.php @@ -0,0 +1,52 @@ + null], + [['image_id', 'sort'], 'integer'], + [['status'], 'boolean'], + [['link'], 'string', 'max' => 255], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'image_id' => Yii::t('app', 'Image ID'), + 'status' => Yii::t('app', 'Status'), + 'sort' => Yii::t('app', 'Sort'), + 'link' => Yii::t('app', 'Link'), + ]; + } +} -- libgit2 0.21.4