Example #1
0
 public static function getSearchLog($input = array())
 {
     $result = Search::where(function ($query) use($input) {
         if (!empty($input['user_id'])) {
             $query = $query->where('user_id', $input['user_id']);
         }
         if (!empty($input['category_id'])) {
             $query = $query->where('category_id', $input['category_id']);
         }
         if (!empty($input['type_id'])) {
             $query = $query->where('type_id', $input['type_id']);
         }
         if (!empty($input['price_id'])) {
             $query = $query->where('price_id', $input['price_id']);
         }
         if (!empty($input['time_id'])) {
             $inputDate = getTime($input['time_id']);
             $query = $query->where('start_time', '>=', $inputDate);
         }
         if (!empty($input['city_id'])) {
             $query = $query->where('city_id', $input['city_id']);
         }
         if (!empty($input['city'])) {
             $query = $query->where('city', $input['city']);
         }
         if (!empty($input['name'])) {
             $query = $query->where('name', 'like', '%' . $input['name'] . '%');
         }
         //lat long
     })->select(listFieldSearch())->get();
     return $result;
 }
 public function searchLog()
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $data = Search::where('user_id', $input['user_id'])->select(listFieldSearch())->get();
     foreach ($data as $key => $value) {
         $categoryName = Category::find($value->category_id)->name;
         $value->name = $value->name . '-' . $categoryName . '-' . $value->city;
     }
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId, $data);
 }