{"id":189,"propertyType":"Hostal","propertyName":"bilal property",
"noOfRoom":"5","streetAddress":"Street no.3 A, Albarar plaze",
"sector":"I Islamabad","Latitude":"64","Longitude":"73","city":"Islamabad",
"internet":"1","parking":null,"mess":"1","TvCabel":null,"RoomCleaning":"1",
"lundary":null,"cctvCamear":null,"updated_at":"2018-04-15 10:01:10",
"created_at":"2018-04-15 10:01:10"}
blade.php
код
{{$success}}
код контроллера
public function insertProperty(Request $request)
{
$user = Auth::user();
$userID = $user->id;
$role = $user->role;
$validator = Validator::make($request->all(), [
'propertyType' => 'required',
'propertyName' => 'required',
'noOfRoom' => 'required',
'streetAddress' => 'required',
'sector' => 'required',
'city' =>'required',
]);
if ($validator->fails()) {
return response()->json(['error'=>$validator->errors()], 401);
}
$property['user_id'] = $request->input('user_id');
$property['role'] = $request->input('role');
$property['propertyType'] = $request->input('propertyType');
$property['propertyName'] = $request->input('propertyName');
$property['noOfRoom'] = $request->input('noOfRoom');
$property['streetAddress'] = $request->input('streetAddress');
$property['sector'] = $request->input('sector');
$property['Latitude'] = $request->input('Latitude');
$property['Longitude'] = $request->input('Longitude');
$property['city'] = $request->input('city');
$property['internet'] = $request->input('internet');
$property['parking'] = $request->input('parking');
$property['mess'] = $request->input('mess');
$property['TvCabel'] = $request->input('TvCabel');
$property['RoomCleaning'] = $request->input('RoomCleaning');
$property['lundary'] = $request->input('lundary');
$property['cctvCamear'] = $request->input('cctvCamear');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://hms.com/api/createProperty",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($property),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
'Authorization' => 'Bearer '.csrf_field(),
),
));
$success= curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return view('error')->with('err',$err);
} else {
return view('adminAction.returnproperty')->with('success',$success);
}
}
//api return
return response()->json($hostal, 201);
Я хочу конвертировать эту строку {{$success}}
в массив
Задача ещё не решена.
Других решений пока нет …