Category : json

my controller public function showcart() { $da = isset($_COOKIE["cart"]) ? $_COOKIE["cart"] : "[]"; $data = json_decode($da); return view(‘customer.showcart’, compact(‘data’)); } blade: <tbody> @foreach ($data as $dat) <form action="{{ url(‘/addcart’) }}" method="post"> @csrf <tr> <td>{{ $dat[‘id’] }}</td> <td>{{ $dat[‘quantity’]}}</td> </tr> </form> @endforeach </tbody> current output {"id":["8","8","8","9","9","8","8","8","10"],"quantity":["3","2","3","3","2","1","2","1","6"]} I want to convert this in JSON with each of ..

Read more

I have problem about queries on laravel. here is code on laravel : $tabel_data= AppModelsData::where(‘data_keys’,’element’)->whereJsonContains(‘data_values->trx_type’,’withdraw’)->get(); here is data on mysql: INSERT INTO `Data`(`id`, `data_keys`, `data_values`) VALUES (‘300′,’element’,'{"id":"300","trx_type":"withdraw","name":"John","date":"2021-09-12","amount":"10","gateway":"USD"}’) the query should be select * from `frontends` where `data_keys` = ‘transaction.element’and JSON_CONTAINS(data_values, ‘"withdraw"’, ‘$.trx_type’); but when running the code it changes to select * from `frontends` where ..

Read more

I’ve made a script like this on my blade <div class="form-group"> <label class="font-weight-bold">PROVINSI</label> <select class="cari_provinsi form-control @error(‘id_provinsi’) is-invalid @enderror" style="" id="id_provinsi" name="id_provinsi" autocomplete="off" required></select> <!– error message untuk title –> @error(‘id_provinsi’) <div class="alert alert-danger mt-2"> {{ $message }} </div> @enderror </div> <div class="form-group"> <label class="font-weight-bold">KOTA</label> <select class="cari_kecamatan form-control @error(‘id_kota’) is-invalid @enderror" style="" id="id_kota" name="id_kota" autocomplete="off" ..

Read more

I would like to add an object into a existing json object : My existing json object : { "id": 1, "horaire_id": 1, "json": "{"i": "idHoraire1-NumReservation1", "x": 3, "y": 2, "w":5, "h": 3, "j": 0}", "num_reserv": 1, "nombre_heures": 7.5, "created_at": "2021-09-16T13:55:00.000000Z", "updated_at": "2021-09-16T13:55:03.000000Z" } And the object to insert into the existing json object : ..

Read more

i am getting response in return response()->json([‘data’ => $res]); array:2 [▼ "response" => "{"ResCode":"TPB013","ResMsg":"Invalid BAR code, please refresh","ResStatus":1,"sign":"w0EQNoxIOkl0K3IKZYKJEPojBrHerRwdTHS4fhAz3n9CxfIprH0QklzgdNaWWzwmBUq++h2U43 ▶" "http_code" => 200 ] {#576 ▼ +"ResCode": "TPB013" +"ResMsg": "Invalid BAR code, please refresh" +"ResStatus": 1 +"sign": "w0EQNoxIOkl0K3IKZYKJEPojBrHerRwdTHS4fhAz3n9CxfIprH0QklzgdNaWWzwmBUq++h2U432d4s5uHmCTjA==" } i want that i get all the response in different veriables like this $responcse = //json res ..

Read more

I’m happy with some updates from my Website but I can’t find out what I am doing wrong. DB::beginTransaction(); try { Log::debug(‘— create —‘); Log::debug($responsible->contactInfo); $firstName = isset($responsible->firstName) ? $responsible->firstName : ‘NoName’; $lastName = isset($responsible->lastName) ? $responsible->lastName : $firstName; $middleName = isset($responsible->middleName) ? $responsible->middleName : ”; if (isset($responsible->contactInfo)) { foreach ($responsible->contactInfo as $key => $value) ..

Read more

I’m trying to construct a clean json with no slashes, but I kept getting them. I’ve been creating array, and encode it like so json_encode($data); all the time. It always works, but this time I got a lot slashes. $data = []; $data[‘input’][‘upload-destination’] = env(‘CONTROLLER_URL’).’/controller/v1/’.$nodeId.’/pkt_capture/upload?port=’.$interface; $data[‘input’][‘upload-username’] = ‘[email protected]’; $data[‘input’][‘upload-password’] = ‘123’; $url = $SERVICE_URL.’/restconf/data/interfaces-state/interface=0%2F’.$interface.’/packet-capture-start’; $data ..

Read more

I can’t wrap my head around this. I have three tables (abbreviated): *images* id | label | … *keywords* id | label | … *image_keyword* image_id | keyword_id And I have their many to many relations defined in the models: *Image.php* public function keywords() { return $this->belongsToMany(Keyword::Class); } *Keyword.php* public function images() { return $this->belongsToMany(Image::Class); } At one point I ..

Read more

I’ve in my React component this function: const url = ‘/category’; function hideOnClick(id) { setHide({value: id}) console.log(id); const body = { ‘chordId’ : id, } const requestMetadata = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json’ }, body: JSON.stringify(body) }; console.log(body); fetch(url, requestMetadata) .then(res => res.json()) .then(res => { this.setState({ url: res }) console.log(res); }) } ..

Read more

I’m sending data with a ajax call to my laravel server at http://127.0.0.1:8000/data Laravel Route Route::post(‘/data’,[MainController::class, ‘data’]); my modle public function up() { Schema::create(‘names’, function (Blueprint $table) { $table->id(); $table->string(‘name’); $table->timestamps(); }); } Controller function data(Request $request) { $requestPayload = file_get_contents("php://input"); $object = json_decode($requestPayload); return ($object); } Json data i want to save in database ..

Read more

In the file config/variables.php I have defined the following objects as a multidimensional array: <?php return [ [ ‘name’ => ‘test1’, ‘surname’ => ‘test1’ ], [ ‘name’ => ‘test2’, ‘surname’ => ‘tes2’ ], [ ‘name’ => ‘tes3’, ‘surname’ => ‘test3’ ] ]; I want to use this data in a Vue component, for example like ..

Read more

I am trying to get data from a database in a HTML file. I am using a laravel API from api.php file for this. Codes from the controller : public function getRegisteredMembersNumber(Request $request){ if ($request->ajax()){ $totalNumbers = ”; $getNumbers = Registration::where(‘category_for’, ‘cyber-security-summit-2021’)- >get(); $totalNumbers .= count($getNumbers); $data = array( ‘getCount’ => $totalNumbers, ); echo json_encode($data); ..

Read more