本文整理汇总了PHP中app\models\Category::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::query方法的具体用法?PHP Category::query怎么用?PHP Category::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Category
的用法示例。
在下文中一共展示了Category::query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
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];
}
示例2: getEdit
public function getEdit($id)
{
$article = Content::query()->findOrFail($id);
$categories = Category::query()->get();
return \View::make('backend.article.edit', ['categories' => $categories, 'article' => $article]);
}
示例3: actionIndex
public function actionIndex()
{
return $this->render(['items' => \app\models\Category::query()->all()]);
}
示例4: category
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]);
}
示例5:
$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