/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MarketingImage::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'marketing_image_name', 'marketing_image_path', 'marketing_image_caption', 'marketing_image_caption_title', 'marketing_image_is_featured', 'marketing_image_is_active', 'marketing_image_weight', 'statusName' => ['asc' => ['status.status_name' => SORT_ASC], 'desc' => ['status.status_name' => SORT_DESC], 'label' => 'Status']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['status']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'marketing_image_name', true);
     $this->addSearchParameter($query, 'marketing_image_path', true);
     $this->addSearchParameter($query, 'marketing_image_caption', true);
     $this->addSearchParameter($query, 'marketing_image_caption_title', true);
     $this->addSearchParameter($query, 'marketing_image_is_featured');
     $this->addSearchParameter($query, 'marketing_image_is_active');
     $this->addSearchParameter($query, 'marketing_image_weight');
     $this->addSearchParameter($query, 'status_id');
     // filter by gender name
     $query->joinWith(['status' => function ($q) {
         $q->andFilterWhere(['=', 'status.status_name', $this->statusName]);
     }]);
     return $dataProvider;
 }
 /**
  * Finds the MarketingImage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return MarketingImage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MarketingImage::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }