public function destroy($id)
 {
     $articleCategory = ArticleCategory::find($id);
     $articleCategory->delete();
     ArticleCategory::fixTree();
     return redirect()->route('dashboard.article_category.index');
 }
 /**
  * Updates an existing ArticleCategory model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => ArticleCategory::find()->noParents()->all()]);
     }
 }
 /**
  * Updates an existing Article model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $this->layout = 'admin';
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['browse']);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => ArticleCategory::find()->active()->all()]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ArticleCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Exemple #5
0
?>

        <?php 
echo $form->field($model, 'file')->fileInput();
?>

        <?php 
echo $model->image ? '<img src="/' . Yii::$app->params['article']['image']['path'] . $model->image . '" height="' . Yii::$app->params['article']['image']['height'] . '">' : '';
?>

        <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>

        <?php 
$listdata = ArrayHelper::map(ArticleCategory::find()->all(), 'id', 'title');
?>
        <?php 
echo $form->field($model, 'category_id')->dropDownList($listdata, ['class' => 'form-control select']);
?>

        <?php 
echo $form->field($model, 'tag')->textInput(['maxlength' => 255]);
?>

        <?php 
echo $form->field($model, 'description')->widget(Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 100, 'plugins' => ['clips', 'fullscreen'], 'imageUpload' => Url::to(['/main/default/image-upload']), 'imageManagerJson' => Url::to(['/main/default/images-get'])]]);
?>

        <?php 
echo $form->field($model, 'preview')->widget(Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 100, 'plugins' => ['clips', 'fullscreen'], 'imageUpload' => Url::to(['/main/default/image-upload']), 'imageManagerJson' => Url::to(['/main/default/images-get'])]]);
Exemple #6
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use Yii;
$this->title = Yii::t('article', 'Articles');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="article-index">
<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php 
echo Html::a(Yii::t('article', 'Create Article'), ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'slug', 'title', ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category ? $model->category->title : null;
}, 'filter' => \yii\helpers\ArrayHelper::map(\app\models\ArticleCategory::find()->all(), 'id', 'title')], ['attribute' => 'author_id', 'value' => function ($model) {
    return $model->author->username;
}], ['attribute' => 'status'], 'published_at:datetime', 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>
</div>