[ 'class' => Index::class, 'columns' => [ 'title' => [ 'type' => Index::ACTION_COL, 'columnConfig' => [ 'buttonsTemplate' => '{edit}{delete}', ], ], 'sort' => [ 'type' => Index::POSITION_COL, ], ], 'model' => Brand::class, 'hasLanguage' => true, 'enableMassDelete' => true, 'modelPrimaryKey' => 'id', ], 'create' => array_merge( [ 'class' => Create::class, 'overwriteEntity' => BrandLang::class, ], $this->fieldsConfig() ), 'update' => array_merge([ 'class' => Update::class ], $this->fieldsConfig()), 'view' => [ 'class' => View::class, 'model' => Brand::class, 'hasAlias' => true, 'hasGallery' => false, 'languageFields' => [ [ 'name' => 'title', 'type' => Form::STRING, ], [ 'name' => 'description', 'type' => Form::WYSIWYG, ], ], 'fields' => [ [ 'name' => 'image', 'type' => Form::IMAGE, ], [ 'name' => 'sort', 'type' => Form::NUMBER, ], [ 'name' => 'status', 'type' => Form::BOOL, ], ], ], 'delete' => [ 'class' => Delete::class, ], ]; } public function findModel($id) { $model = Brand::find() ->with('languages') ->where([ 'id' => $id ]) ->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } public function newModel() { return new Brand(); } public function deleteModel($id) { $category = Brand::find() ->with('languages') ->where( [ 'id' => $id, ] ) ->one(); return $category->delete(); } protected function fieldsConfig() { return [ 'model' => Brand::class, 'hasAlias' => false, 'hasGallery' => false, 'languageFields' => array_merge( [ [ 'name' => 'title', 'type' => Form::STRING, ], [ 'name' => 'alias', 'type' => Form::STRING, 'slugify' => 'title' ], [ 'name' => 'description', 'type' => Form::WYSIWYG, ], ], $this->module->brandLanguageFields ), 'fields' => array_merge( [ [ 'name' => 'image', 'type' => Form::IMAGE, ], [ 'name' => 'status', 'type' => Form::BOOL, ], [ 'name' => 'sort', 'type' => Form::NUMBER, ], ], $this->module->brandFields ), ]; } }