/**
  * @return array
  * handel search conditions
  */
 function handel_search()
 {
     $query = Schedule::find();
     switch ($_REQUEST['st']) {
         case 1:
             $_REQUEST['search_input'] ? $arr['employee_id'] = Employee::findOne(['name' => $_REQUEST['search_input']])->id : '';
             //search  employee name
             break;
         case 2:
             //($_REQUEST['search_input'])?$arr['mobile']=$_REQUEST['search_input']:'';
             $_REQUEST['search_input'] ? $condition['mobile'] = $_REQUEST['search_input'] : '';
             break;
         default:
     }
     $arr['agency_id'] = Yii::$app->user->identity->id;
     $query->where($arr);
     if ($_REQUEST['st']) {
         //($_REQUEST['status'])?$arr['job_id']=PostJob::findOne(['job_status'=>$_REQUEST['status']])->id:'';      //search job status
         // ($_REQUEST['service_type'])?$arr['job_id']=$_REQUEST['service_type']:'';                //search service_type
         $_REQUEST['status'] ? $condition['job_status'] = $_REQUEST['status'] : '';
         $_REQUEST['service_type'] ? $condition['service_type'] = $_REQUEST['service_type'] : '';
         $res = PostJob::find()->where($condition)->all();
         if (count($res) > 0) {
             foreach ($res as $k => $v) {
                 $ids[] = $v->id;
             }
             $query->andWhere(['in', 'job_id', $ids]);
         } else {
             $query->andWhere(['job_id' => '-1']);
         }
     }
     return $query;
 }
Esempio n. 2
0
 /**
  * @param Request $request
  */
 public function get(Request $request)
 {
     // find out if this is calling the ID or the airport identifier
     if ($request->has('depicao')) {
         $route = Schedule::where('depicao', $request->depicao)->get();
     }
     if ($request->has('arricao')) {
         $route = Schedule::where('arricao', $request->arricao)->get();
     }
     if ($request->has('id')) {
         $route = Schedule::find($request->id);
     }
     return $route;
 }