Category : json

I’m trying to fetch data from an external API with laravel. This is how I do it : use IlluminateSupportFacadesHttp; [..] $response = Http::get(‘http://localhost:3000/api/movies’); dd($response->json()); // it’s null dd($response->collect()); // it’s null dd($response->object()); // it’s null //for debugging purpose $response->ok() // this output true $response->successful() //this output true $response->failed() : bool; //this output false $response->serverError() ..

Read more

I have a problem about decodable the "product" from laravel api request. Error is "The data couldn´t be read because it isn´t in the correct format. request with insomnia is right and i get the product where the ean number has. Laravel for database: Schema::create(‘products’, function (Blueprint $table) { $table->id(); $table->bigInteger(‘ean’); $table->string(‘name’); $table->string(‘manufacturer’); $table->string(‘productNumber’); $table->longText(‘description’)->nullable(); ..

Read more

I am trying to get latest messages from table ‘messages’ for inbox The chat is between user and owner of the item (listed on my portal) I want to get unique data with item_id My code is public function inbox() { // $inbox = ChatMessage::distinct(‘item_id’)->where(‘incoming_msg_id’, auth()->user()->id)->orWhere(‘outgoing_msg_id’, auth()->user()->id)->orderBy(‘msg_id’, ‘DESC’)->get(); $inbox = Message::where(‘incoming_msg_id’, auth()->user()->id)->orWhere(‘outgoing_msg_id’, auth()->user()->id)->latest(‘msg_id’)->get()->unique(‘item_id’); return $this->sendResponse($inbox,’Chat’); ..

Read more

i want to get an array with people back to my javascript popup but i gives me array(0) javascript ————————————————————————————————- function showPopup(modal_id, board_id){ var url = route(‘getCardInfo’, [modal_id, board_id]) let token = document.querySelector(‘meta[name="csrf-token"]’).getAttribute(‘content’) fetch(url, { headers: { "Content-Type": "application/json", "Accept": "application/json, text-plain, *//* only 1 line ", "X-Requested-With": "XMLHttpRequest", "X-CSRF-TOKEN": token, }, method: ‘GET’, credentials: ..

Read more

I premise that I’m new to the Laravel environment. I have this JSON file in the database { "48:CE:B8:09:7D:AD": ["-91"], "70:61:91:66:6B:1E": ["-81", "-69", "-79", "-65", "-74"], "4B:6F:42:53:EB:82": ["-84", "-73", "-81"], "77:87:80:27:2B:31": ["-83", "-70", "-82", "-71", "-79", "-71", "-79", "-71", "-80", "-72"], "43:FD:25:20:5A:7B": ["-76", "-84", "-76", "-88", "-77", "-86"], "C1:04:08:03:3C:05": ["-73"], "7F:D2:44:60:82:BD": ["-88", "-79", "-88"], "FE:47:DA:73:90:29": ..

Read more

i have alot of records that needs to be edited in one request, so i went for POST request to try to edit the data in my controller like this : foreach ($attr as $key){ foreach ($key->item as $attribute) { if ($attribute[‘action’] == ‘store’) { $insert_array = [ ‘subject_quiz_id’ => $key->subject_quiz_id, ‘registration_record_id’ => $attribute->registration_record_id, ‘mark’ ..

Read more

I’m trying to install maatwebsite/excel package to my laravel with this command composer require maatwebsite/excel but i got this error message instead: Your requirements could not be resolved to an installable set of packages. Problem 1 – maatwebsite/excel[3.1.28, …, 3.1.30] require phpoffice/phpspreadsheet 1.16.* -> satisfiable by phpoffice/phpspreadsheet[1.16.0]. – maatwebsite/excel[3.1.31, …, 3.1.x-dev] require phpoffice/phpspreadsheet ^1.18 -> ..

Read more

I created an array/object in controller: $animals[‘data’] = Animal::with(‘animalsCategory’,’keepers’,’equipments’)->get(); return json_encode($animals); I need it to DataTables so it will be in JSON. It looks like this: data: [{id: 1, animals_categories_id: 1, name: "Baloo", description: null, health_id: null,…},…] 0: {id: 1, animals_categories_id: 1, name: "Baloo", description: null, health_id: null,…} animals_categories_id: 1 animals_category: {id: 1, name: "Spiders", ..

Read more

While returning data from laravel routes or controllers, they are automatically returned as JSON data. That’s cool but reading these data into the web page it’s difficult. Because they’re inline, and it’s hard to identify elements. I know I could use something like: https://jsonformatter.curiousconcept.com/#. To format the json data to be readable. But I was ..

Read more

I’m working with Laravel 5.8 and I wanted to build a Keyword Tag Manager system. So the form should be looked like this: And here is the code: <div class="row keywords"> <div class="col-md-4 keyword-item" data-information="{{ !empty($product) ? $product->prd_meta_keywords : ” }}"> <div class="form-group"> <label>Keyword</label> <div class="input-group mb-3 flex-row-reverse"> <div class="input-group-prepend"> <span class="input-group-text"><i class="fa fa-plus-circle text-success ..

Read more

blog:{ postTitle: ”, } this is in JS let data = new FormData(); const blog = JSON.stringify(this.blog); data.append(‘blog’,blog); Laravel $blog = json_decode(request(‘blog’)); $blog->validate([ ‘blog.postTitle’ => ‘required’ ]); I have tried to: after I decode it I have tried to: return $request[‘blog’] and it works. Error for validation I get is: Call to undefined method stdClass::validate() ..

Read more