public function search($input) { $query = Category::query(); $columns = Schema::getColumnListing('categories'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }
public function getEdit($id) { $article = Content::query()->findOrFail($id); $categories = Category::query()->get(); return \View::make('backend.article.edit', ['categories' => $categories, 'article' => $article]); }
public function actionIndex() { return $this->render(['items' => \app\models\Category::query()->all()]); }
public function category(Route $route) { $category = Category::query()->where('slug', '=', $route->parameter('category'))->firstOrFail(); $articles = Content::query()->where('category_id', '=', $category->id)->where('active', '=', '1')->orderBy('publish_at', 'desc')->paginate(1); return \View::make('frontend.category', ['category' => $category, 'articles' => $articles]); }
$form = ActiveForm::begin(['id' => 'contact-form', 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'header')->label('Название'); ?> <?php echo $form->field($model, 'description')->label('Описание')->hint('код HTML')->textarea(['rows' => 10]); ?> <?php echo $model->field($form, 'content'); ?> <?php echo $form->field($model, 'image')->label('Картинка')->widget('cs\\Widget\\FileUpload2\\FileUpload'); ?> <?php echo $form->field($model, 'parent_id')->label('Родительский')->radioList(ArrayHelper::map(\app\models\Category::query()->all(), 'id', 'header')); ?> <hr class="featurette-divider"> <div class="form-group"> <?php echo Html::submitButton('Обновить', ['class' => 'btn btn-default', 'name' => 'contact-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> <?php