コード例 #1
0
 public function search($params)
 {
     $query = Source::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
     $query->andFilterWhere([source::tableName() . '.status' => '1']);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdOn' => $this->createdOn, 'status' => $this->status, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Source::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: _form.php プロジェクト: rajanishtimes/partnerapi
use common\models\Source;
/**
 * @var yii\web\View $this
 * @var app\models\Restaurant $model
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="restaurant-form">

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

    <?php 
echo $form->field($model, 'sourceId')->dropDownList(ArrayHelper::merge([0 => 'Select'], ArrayHelper::map(Source::find()->andWhere(['status' => 1])->All(), 'Id', 'name')));
?>
    
    <?php 
echo $form->field($model, 'entityType')->dropDownList([0 => 'Select', 1 => 'Restaurant', 2 => 'Nightlife']);
?>

    <?php 
echo $form->field($model, 'cityId')->dropDownList(ArrayHelper::merge([0 => 'Select'], ArrayHelper::map(\common\models\City::find()->andWhere(['status' => 1])->All(), 'Id', 'name')));
?>
    
    <?php 
//$form->field($model, 'chainId')->dropDownList(ArrayHelper::merge([0=>'Select'], ArrayHelper::map(Brands::find()->andWhere(['status'=>1])->All(), 'Id', 'name')))
?>

    <?php 
コード例 #4
0
 /**
  * Finds the Source model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Source the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Source::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: Post.php プロジェクト: alexsynytskiy/Dynamomania
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         // source
         if (isset($this->source_id) && $this->source_id > 0) {
             $source = Source::findOne($this->source_id);
             if (isset($source)) {
                 $this->source_title = $source->name;
                 $this->source_url = $source->url;
             }
         }
         // slug
         $this->slug = $this->genSlug($this->title);
         // created_at
         $this->created_at = date('Y-m-d H:i:s', strtotime($this->created_at));
         // content
         //            $pattern = '~<a .*href=".*" .*>(.*)</a>~U';
         //            $this->content = preg_replace($pattern, '$1', $this->content);
         // Selected blogs
         if (isset($this->selected_blog)) {
             if ($this->selected_blog) {
                 $selectedBlog = SelectedBlog::find()->where(['post_id' => $this->id])->one();
                 if (!isset($selectedBlog)) {
                     $selectedBlog = new SelectedBlog();
                     $selectedBlog->post_id = $this->id;
                     $selectedBlog->save(false);
                 }
             } else {
                 SelectedBlog::deleteAll(['post_id' => $this->id]);
             }
         }
         return true;
     } else {
         return false;
     }
 }