public function index(Manager $fractal, SupportTransformer $transformer, $customerID)
 {
     $ac = ArticleCategory::where('id', '>=', 64)->take(10)->get();
     $resource = new Collection($ac, $transformer);
     $data = $fractal->createData($resource)->toArray();
     return $this->respondWithSuccess($data);
 }
 /**
  * @param Category $except
  *
  * @return CategoriesController
  */
 protected function getCategoryOptions($except = null)
 {
     /** @var \Kalnoy\Nestedset\QueryBuilder $query */
     $query = ArticleCategory::select('id', 'category_name')->withDepth();
     if ($except) {
         $query->whereNotDescendantOf($except)->where('id', '<>', $except->id);
     }
     return $this->makeOptions($query->get());
 }
 public function index($id = 0)
 {
     if ($id) {
         $category = ArticleCategory::with(['articles' => function ($query) {
             $query->take(20)->orderBy('created_time', 'DESC');
         }])->find($id);
         return view('front.article-category.index', compact('category'));
     }
 }
 /**
  * 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;
 }
Example #6
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $currentRoute = Route::currentRouteName();
     //查询分类
     $articleCategory = ArticleCategory::all()->toTree();
     //社区分类
     $communityCategory = CommunityCategory::all()->toTree();
     //查询配置项
     $settings = Settings::all();
     foreach ($settings as $key => $value) {
         $options[$value['name']] = $value['value'];
     }
     //查询登录用户
     $user = Auth::guard('web')->user();
     $view->with('loginUser', $user)->with('currentRoute', $currentRoute)->with('articleCategory', $articleCategory)->with('communityCategory', $communityCategory)->with($options);
 }
 /**
  * Finds the ArticleCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ArticleCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ArticleCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('article', 'The requested page does not exist.'));
     }
 }
Example #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(ArticleCategory::className(), ['id' => 'category_id']);
 }
Example #9
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'])]]);
 public function compose(View $view)
 {
     $article_categories = ArticleCategory::defaultOrder()->get()->toTree();
     $view->with('article_categories', $article_categories);
 }
Example #11
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>