예제 #1
0
 /**
  * Lists all Goods models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new GodosSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $cates = Category::find()->all();
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cates' => $cates]);
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'pid' => $this->pid, 'level' => $this->level, 'cover' => $this->cover, 'sort' => $this->sort, 'is_leaf' => $this->is_leaf, 'created_at' => $this->created_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]);
     return $dataProvider;
 }
예제 #3
0
파일: _form.php 프로젝트: cboy868/nana
use yii\helpers\Html;
use common\components\widgets\ActiveForm;
use shop\models\Category;
/* @var $this yii\web\View */
/* @var $model shop\models\Category */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="category-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'pid')->dropDownList(Category::selTree(), ['prompt' => '顶级']);
?>

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

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

    <?php 
echo $form->field($model, 'body')->textarea(['rows' => 6]);
?>

	<div class="form-group">
예제 #4
0
파일: _form.php 프로젝트: cboy868/nana
/* @var $model shop\models\Attr */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="attr-form">

    <?php 
$form = ActiveForm::begin();
?>

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

    <?php 
echo $form->field($model, 'category_id')->dropDownList(Category::selTree());
?>

    <?php 
echo $form->field($model, 'is_multi')->radioList(['否', '是']);
?>

    <?php 
echo $form->field($model, 'body')->textarea(['rows' => 6]);
?>

	<div class="form-group">
        <div class="col-sm-offset-2 col-sm-3">
            <?php 
echo Html::submitButton('保 存', ['class' => 'btn btn-primary btn-block']);
?>
예제 #5
0
 /**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Category::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }