/** * @param $request * @route 'api/activity/add' * @return Response */ public function addActivity(Request $request) { $error_bag = []; $request = $request->all(); $type = $request['type']; $token = $request['token']; if ($type == "transport" || $type == 'transpo') { $origin_name = $request['place_name']; $lng = $request['lng']; $lat = $request['lat']; $mode = $request['mode']; $price = $request['price']; $input_bag = ['origin name ' => $origin_name, 'longitude ' => $lng, 'latitude ' => $lat, 'mode' => $mode]; $i = 0; foreach ($input_bag as $key => $value) { $value = trim($value); if (empty($value)) { $error_bag[$i] = "{$key} empty"; $i++; } else { // } } //filter of false or null values if (array_filter($error_bag)) { return response()->json($error_bag, 400); } return UserSessionHandler::addSegment($token, $origin_name, $lng, $lat, $mode); } if ($type == 'food') { $food = $request['food']; $transpo = $request['transpo']; $input = ['food' => $food, 'transpo' => $transpo]; // return response()->json($input); // $input_bag = [ // 'food object is ' => $food // ]; // return response()->json('err dre dit'); // // $i = 0; // foreach ($input_bag as $key => $value) { // $value = trim($value); // // if (empty($value)) { // $error_bag[$i] = "$key empty"; // $i++; // } else { // // // } // } // //filter of false or null values // if (array_filter($error_bag)) { // return response()->json($error_bag, 400); // } // return response()->json($food); return UserSessionHandler::addFood($token, $food, $transpo); // return response()->json(UserSessionHandler::addFood($token, $food, $transpo),403); } if ($type == "spots" || $type == 'spot') { $spot = $request['spot']; $transpo = $request['transpo']; return UserSessionHandler::addSpot($token, $spot, $transpo); // return response()->json(UserSessionHandler::addSpot($token, $spot,$transpo),403); } if ($type == 'hotel') { //todo $hotel = $request['hote']; $transpo = $request['transpo']; dd($request); return UserSessionHandler::addHotel($token, $hotel, $transpo); } if ($type == 'stop') { $stop = $request['stop']; $transpo = $request['transpo']; return UserSessionHandler::addStop($token, $stop, $transpo); } if ($type == 'others') { $others_data = $request['others']; $transpo = $request['transpo']; return UserSessionHandler::addOtherActivity($token, $others_data, $transpo); } else { return response()->json('type field is required', 200); } }