/**
  * 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]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['idcategory' => $this->idcategory, 'created' => $this->created, 'modified' => $this->modified, 'published' => $this->published, 'trashed' => $this->trashed, 'owner' => $this->owner]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
 private function getCategory($timestamp)
 {
     $assignedData = array();
     $updatedData = array();
     $data = array();
     $status = array('code' => '0', 'errorMessage' => "");
     if ($timestamp == 0) {
         $assignedData = Category::find()->asArray()->all();
     } else {
         $assignedData = Category::find()->where('published = 1 And :timestamp < UNIX_TIMESTAMP(created)', [':timestamp' => $timestamp])->asArray()->all();
         $updatedData = Category::find()->where('published = 1 And ((:timestamp >= UNIX_TIMESTAMP(created) And :timestamp <= UNIX_TIMESTAMP(modified)))', [':timestamp' => $timestamp])->asArray()->all();
     }
     $data['assignedData'] = $assignedData;
     $data['updatedData'] = $updatedData;
     return ['status' => $status, 'data' => $data];
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdcategory0()
 {
     return $this->hasOne(Category::className(), ['idcategory' => 'idcategory']);
 }
Example #4
0
<?php

use vendor\kabira\tookee\models\Category;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model vendor\kabira\tookee\models\News */
/* @var $form yii\widgets\ActiveForm */
?>

<?php 
$categories = Category::find()->orderby('title')->all();
$categories = ArrayHelper::map($categories, 'idcategory', 'title');
?>

<div class="news-form">
    <?php 
$form = ActiveForm::begin();
?>

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

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

    <?php 
echo $form->field($model, 'matter')->textarea(['rows' => 5]);
 /**
  * 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.');
     }
 }