/**
* Lists all Job models.
* @return mixed
*/
public function actionIndex()
{
$model = new Job();
// This is used to search/filter organizations
$dataProvider = null;
if (isset($_GET['user_id'])) {
$user_id = $_GET['user_id'];
if ($user_id !== null) {
$query = new Query();
$query->from(Job::tableName());
$query->where(['user_id' => $user_id]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
}
} else {
$dataProvider = new ActiveDataProvider(['query' => Job::find(), 'pagination' => ['pageSize' => 5]]);
}
if ($model->load(Yii::$app->request->post())) {
$query = new Query();
$query->from(Job::tableName());
if (!is_null($model->employment_type) && is_array($model->employment_type)) {
$query->where(['employment_type' => array_map('intval', $model->employment_type)]);
}
if (!is_null($model->job_type) && is_array($model->job_type)) {
$query->where(['job_type' => array_map('intval', $model->job_type)]);
}
if (!is_null($model->work_domain) && is_array($model->work_domain)) {
$query->andWhere(['work_domain' => array_map('intval', $model->work_domain)]);
}
if (isset($_GET['user_id'])) {
$query->andWhere(['user_id' => $_GET['user_id']]);
}
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
}
return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]);
}