本文整理汇总了PHP中Illuminate\Support\Facades\Input::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::json方法的具体用法?PHP Input::json怎么用?PHP Input::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
/**
* Inserts a value from JSON input. The input should be formatted like this:
* {
* 'chart_id': <chart id> [integer]
* 'auth': <chart auth> [string]
* 'value': <chart value> [double]
* }
*
* @return \Illuminate\Http\JsonResponse
*/
public function insert()
{
if (Input::isJson()) {
$input = Input::json()->all();
try {
$chart = Chart::findOrFail($input['chart_id']);
} catch (ModelNotFoundException $e) {
return response()->json(['success' => false, 'message' => 'Chart not found'], 400);
}
// Check if correct chart password
if ($input['auth'] === $chart['auth']) {
$val = $input['value'];
if (!$chart->insertValue($val)) {
// Error while inserting
return response()->json(['success' => false, 'message' => 'Error inserting value'], 400);
}
// Successful insert
return response()->json(['success' => true, 'message' => 'Value successfully inserted'], 200);
} else {
return response()->json(['success' => false, 'message' => 'Incorrect auth for chart'], 401);
}
} else {
return response()->json(['success' => false, 'message' => 'Incorrect input type. Expected JSON'], 400);
}
}
示例2: login
public function login()
{
//echo "Came to validation part>>>!";
if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
return Response::json(Auth::user());
} else {
return Response::json(array('flash' => 'Invalid username or password'), 500);
}
}
示例3: postAllfundamentaldetails
public function postAllfundamentaldetails()
{
$serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
$user = $this->GetSessionUser($serviceRequest->Token);
if ($user->IsSuccess) {
$serviceResponse = $this->DataProvider->AllFundamentalDetails($serviceRequest->Data);
} else {
$serviceResponse = $user;
}
return $this->GetJsonResponse($serviceResponse);
}
示例4: postTransaction
/**
* @param LaravelMixpanel $mixPanel
*/
public function postTransaction(LaravelMixpanel $mixPanel)
{
$data = Input::json()->all();
if (!$data || !array_key_exists('data', $data)) {
throw new Exception('Missing "data" parameter in Stripe webhook POST request: ' . $data);
}
$transaction = $data['data']['object'];
$originalValues = array_key_exists('previous_attributes', $data['data']) ? $data['data']['previous_attributes'] : [];
$stripeCustomerId = $this->findStripeCustomerId($transaction);
$user = App::make(config('auth.model'))->where('stripe_id', $stripeCustomerId)->first();
if (!$user) {
return;
}
$mixPanel->identify($user->id);
if ($transaction['object'] === 'charge' && !count($originalValues)) {
$this->recordCharge($mixPanel, $transaction, $user);
}
if ($transaction['object'] === 'subscription') {
$this->recordSubscription($mixPanel, $transaction, $user, $originalValues);
}
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$this->model->update($id, Input::json()->all());
}
示例6: postDeletefundamental
public function postDeletefundamental()
{
$serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
$serviceResponse = $this->DataProvider->DeleteFundamental($serviceRequest->Data);
return $this->GetJsonResponse($serviceResponse);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$key = Input::get('key');
$json = Input::all();
//print_r($json);
/*
->join('members as m','d.merchant_id=m.id','left')
->where('assignment_date',$indate)
->where('device_id',$dev->id)
->and_()
->group_start()
->where('status',$this->config->item('trans_status_admin_courierassigned'))
->or_()
->group_start()
->where('status',$this->config->item('trans_status_new'))
->where('pending_count >', 0)
->group_end()
->group_end()
*/
if (is_null($key) || $key == '') {
$actor = 'no id : no name';
\Event::fire('log.api', array($this->controller_name, 'post', $actor, 'empty key'));
return \Response::json(array('status' => 'ERR:EMPTYKEY', 'timestamp' => time(), 'message' => 'Empty Key'));
}
$app = \Application::where('key', '=', $key)->first();
if ($app) {
$jsons = Input::json();
$model = new \Shipment();
$merchant_id = $app->merchant_id;
$app_id = $app->id;
$app_key = $app->key;
$result = array();
/*
foreach ($jsons as $json) {
$order = $this->ordermap;
print_r($json);
}
die();
*/
foreach ($jsons as $json) {
//print_r($json);
$order = $this->ordermap;
if (isset($json['pick_up_date'])) {
if (is_array($json['pick_up_date']) && isset($json['pick_up_date']['sec'])) {
$pick_up_date = date('Y-m-d H:i:s', $json['pick_up_date']['sec']);
} else {
$pick_up_date = $json['pick_up_date'];
}
} else {
$pick_up_date = date('Y-m-d H:i:s', time());
}
$codval = doubleval($json['cod']);
//$codval = floor($codval * 100) / 100;
$codval = round($codval, 0, PHP_ROUND_HALF_UP);
$order['buyerdeliveryzone'] = isset($json['district']) ? $json['district'] : '';
$order['merchant_trans_id'] = $json['no_sales_order'];
$order['buyerdeliverytime'] = $pick_up_date;
$order['fulfillment_code'] = $json['consignee_olshop_orderid'];
$order['box_count'] = $json['number_of_package'];
$order['delivery_type'] = trim($json['delivery_type']);
$order['total_price'] = $codval;
$order['email'] = $json['email'];
$order['buyer_name'] = $json['consignee_olshop_name'];
$order['recipient_name'] = $json['consignee_olshop_name'];
$order['shipping_address'] = $json['consignee_olshop_addr'];
$order['buyerdeliverycity'] = $json['consignee_olshop_city'];
$order['shipping_zip'] = $json['consignee_olshop_zip'];
$order['phone'] = $json['consignee_olshop_phone'];
$order['delivery_bearer'] = 'merchant';
$order['cod_bearer'] = 'merchant';
$order['actual_weight'] = strval($json['w_v']);
$weight = $json['w_v'];
$delivery_type = trim($json['delivery_type']);
$order['weight'] = \Prefs::get_weight_tariff($weight, $delivery_type, $app_id);
$order['merchant_id'] = $merchant_id;
$order['application_id'] = $app_id;
$order['application_key'] = $app_key;
$trx_detail = array();
$trx_detail[0]['unit_description'] = $json['consignee_olshop_desc'];
$trx_detail[0]['unit_price'] = $json['cod'];
$trx_detail[0]['unit_quantity'] = 1;
$trx_detail[0]['unit_total'] = $json['cod'];
$trx_detail[0]['unit_discount'] = 0;
$order['trx_detail'] = $trx_detail;
$trx_id = $order['merchant_trans_id'];
$trx = json_encode($order);
$order['merchant_trans_id'] = $json['no_sales_order'];
$order['fulfillment_code'] = $json['consignee_olshop_orderid'];
$inlog = $json;
$inlog['ts'] = new \MongoDate();
unset($inlog['_id']);
//.........这里部分代码省略.........
示例8: postAllcurrentcalllist
public function postAllcurrentcalllist()
{
$ServiceResponse = new ServiceResponse();
$CallDataProvider = new CallDataProvider();
$serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
$cUser = $this->GetSessionUser($serviceRequest->Token);
if ($cUser->IsSuccess) {
$ServiceResponse = $CallDataProvider->AllCurrentcalllist($serviceRequest->Data);
} else {
$ServiceResponse = $cUser;
}
return $this->GetJsonResponse($ServiceResponse);
}
示例9: friendsHelpNeeded
public function friendsHelpNeeded()
{
$input = Input::json();
$facebookIDs = $input->get('idPlayers');
$response = ['friends' => []];
foreach ($facebookIDs as $fid) {
$jugador = Jugador::where('idFacebook', '=', $fid)->first();
if ($jugador) {
$cantidadDerrotas = Puntaje::where('idPlayer', '=', $jugador->idPlayer)->where('defeated', '=', 1)->count();
if ($cantidadDerrotas > $jugador->continues) {
$response['friends'][] = ['idPlayer' => $jugador->idPlayer, 'idFacebook' => $jugador->idFacebook];
}
}
}
return Response::json($response, 200);
}
示例10: updateDroppingDetails
/**
* Url:
* /public/api/v1.0/update/bus/destination/{dropping_id}
*
* Payload:
{
"params": {
"buses_id": 27,
"bus_departure_points_id": 5,
"dropping_point": "Tada",
"dropping_time": "9am",
"price": "1003"
}
}
*/
public function updateDroppingDetails(Request $request)
{
$data = Input::json()->all();
$response = $this->response;
$validateAndHandleError = new ValidateAndHandleError();
if (!Auth::user()->id) {
return $validateAndHandleError->invalidUser();
}
if (!$request->route('dropping_id')) {
return $response->errorResponse("dropping_id_not_exist");
}
$dropping_id = $request->route('dropping_id');
if (!isset($data) || !isset($data['params']) || !isset($data['params']['buses_id']) || !isset($data['params']['bus_departure_points_id']) || !isset($data['params']['dropping_point']) || !isset($data['params']['place_id']) || !isset($data['params']['dropping_time']) || !isset($data['params']['price'])) {
return $response->errorResponse('invalid_params');
// return $validateAndHandleError->errorIdentifier("invalid_params");
}
$buses_id = $data['params']['buses_id'];
$bus_departure_points_id = $data['params']['bus_departure_points_id'];
$dropping_point = $data['params']['dropping_point'];
$dropping_time = $data['params']['dropping_time'];
$place_id = $data['params']['place_id'];
$price = $data['params']['price'];
/* Null validation */
$validateNullData = array("buses_id" => $buses_id, "bus_departure_points_id" => $bus_departure_points_id, "dropping_point" => $dropping_point, "dropping_time" => $dropping_time, "price" => $price, "place_id" => $place_id);
$nullValidator = $validateAndHandleError->multiValidator($validateNullData, "string");
if ($nullValidator != "success") {
return $nullValidator;
}
/* Bus id is number or not */
$validateBusId = $validateAndHandleError->multiValidator(['buses_id' => $buses_id, 'dropping_id_not_number' => $dropping_id, 'place_id' => $place_id, 'departure_id_not_number' => $bus_departure_points_id], "number");
if ($validateBusId != "success") {
return $validateBusId;
}
$place = Place::where('id', $place_id)->get()[0]->place;
if ($place != $dropping_point) {
return $response->errorResponse('to_place_mismatch');
// return $validateAndHandleError->errorIdentifier("to_place_mismatch");
}
/* Validate dropping id present in db or not */
$check_dropping_id = BusDroppingPoint::where('id', $dropping_id)->get();
if (count($check_dropping_id) <= 0) {
return $response->errorResponse("dropping_details_not_available");
}
/* for this dropping id check bus_id and departure id is matching or not */
if ($check_dropping_id[0]->buses_id != $buses_id || $check_dropping_id[0]->bus_departure_points_id != $bus_departure_points_id) {
return $response->errorResponse("bus_id_and_departure_id_mismatch");
}
/* Bus id exist or not */
$check_bus_availability = Bus::where('id', $buses_id)->get();
if (count($check_bus_availability) <= 0) {
return $response->errorResponse("bus_details_not_available");
}
/* Departure id exist or not */
$prev_departure_details = BusDeparturePoint::where('id', $bus_departure_points_id)->get();
if (count($prev_departure_details) <= 0) {
return $response->errorResponse('bus_departure_details_does_not_exist');
// return $validateAndHandleError->errorIdentifier("bus_departure_details_does_not_exist");
}
/* bus id passed through param should be equal with bus id of db */
if ($prev_departure_details[0]->buses_id != $buses_id) {
return $response->errorResponse('invalid_departure_details');
// return $validateAndHandleError->errorIdentifier("invalid_departure_details");
}
$user_id = Auth::user()->id;
$bus_owners_id = $check_bus_availability[0]->bus_owners_id;
/* $user_id_temp is used to check whether the details are accessible or not */
$user_id_temp = BusOwner::where('id', $bus_owners_id)->get()[0]->user_id;
$user_type = $validateAndHandleError->userIdentifier($user_id);
/* details are only accessible by admin and bus owner */
if ($user_type == "customer" || $user_type == "dealer" || $user_type == "unknown" || $user_type == "bus_owner" && $user_id_temp != $user_id) {
return $response->errorResponse("details_not_accessible");
}
$is_dropping_details_updated = BusDroppingPoint::where('id', $dropping_id)->where('buses_id', $buses_id)->where('bus_departure_points_id', $bus_departure_points_id)->update(['dropping_point' => $dropping_point, 'dropping_time' => $dropping_time, 'price' => $price]);
$info = array('bus_dropping_id' => $dropping_id, 'bus_id' => $buses_id, 'bus_owners_id' => $bus_owners_id, 'departure_id' => $bus_departure_points_id, 'dropping_point' => $dropping_point, 'dropping_time' => $dropping_time, 'price' => $price);
if ($is_dropping_details_updated == 1) {
return $response->successResponse(200, "Bus dropping details has been updated successully", $info);
}
return $response->errorResponse("update_unsuccessfull");
}
示例11: postEnableGroup
public function postEnableGroup()
{
$serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
$serviceResponse = $this->GroupDataProvider->EnableGroup($serviceRequest->Data);
return $this->GetJsonResponse($serviceResponse);
}
示例12: inputsArray
/**
* Get the inputs as an array.
*
* @param bool $jsonInput JSON or not
*
* @return array
*/
private static function inputsArray($jsonInput)
{
if ($jsonInput) {
$inputs = Input::json();
} else {
$inputs = Input::all();
// Don't send the token back
unset($inputs['_token']);
foreach ($inputs as $key => $value) {
if (Input::file($key)) {
unset($inputs[$key]);
}
}
}
return $inputs;
}
示例13: all
/**
* @return array
*/
public static function all()
{
return Request::isJson() ? Input::json()->all() : Input::all();
}
示例14: submit
public function submit()
{
$payload = Input::json();
Log::info('payload: ' . var_export($payload, true));
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($questionId, $id)
{
return $this->model->update($id, Input::json()->all());
}