skip to Main Content

I’am trying debug with dd() in laravel application, but in preview in network of my http request I’m getting this script instad of preview of data which should be in array of $all_ids

%3Cscript%3E%20Sfdump%20%3D%20window.Sfdump%20%7C%7C%20(function%20(doc)%20%7B%20doc.documentElement.classList.add('sf-js-enabled')%3B%20var%20rxEsc%20%3D%20%2F(%5B.*%2B%3F%5E%24%7B%7D()%7C%5C%5B%5C%5D%5C%2F%5C%5C%5D)%2Fg%2C%20idRx%20%3D%20%2F%5Cbsf-dump-%5Cd%2B-ref%5B012%5D%5Cw%2B%5Cb%2F%2C%20keyHint%20%3D%200%20%3C%3D%20navigator.platform.toUpperCase().indexOf('MAC')%20%3F%20'Cmd'%20%3A%20'Ctrl'%2C%20addEventListener%20%3D%20function%20(e%2C%20n%2C%20cb)%20%7B%20e.addEventListener(n%2C%20cb%2C%20false)%3B%20%7D%3B%20if%20(!doc.addEventListener)%20%7B%20addEventListener%20%3D%20function%20(element%2C%20eventName%2C%20callback)%20%7B%20element.attachEvent('on'%20%2B%20eventName%2C%20function%20(e)%20%7B%20e.preventDefault%20%3D%20function%20()%20%7Be.returnValue%20%3D%20false%3B%7D%3B%20e.target%20%3D%20e.srcElement%3B%20callback(e)%3B%20%7D)%3B%20%7D%3B%20%7D%20function%20toggle(a%2C%20recursive)%20%7B%20var%20s%20%3D%20a.nextSibling%20%7C%7C%20%7B%7D%2C%20oldClass%20%3D%20s.className%2C%20arrow%2C%20newClass%3B%20if%20(%2F%5Cbsf-dump-...

It worked 30 mins ago, I did try clear cache, but it didn’t help. This is code where I’m using dd()

  public function viewAllProductInfo(Request $request)
    {
        $all_ids = $request->id;
        foreach ($all_ids as $id) {
            dd($all_ids);
            $storeItemProduct = StoreItemProduct::findOrFail($id);
            event(new StoreViewItemProductLabelEvent($storeItemProduct, $request->all()));
        }
    }

I hope that this post find somebody who hase experience with this.

3

Answers


  1. You can use the dd() at strategic positions in your code as follows,
    not that in the foreach loop you dump the specific id, not the array anymore

    public function viewAllProductInfo(Request $request)
    {
        $all_ids = $request->id;
        dd($all_ids); // Dump the $all_ids array before entering the loop
        foreach ($all_ids as $id) {
            dd($id); // Dump each $id before fetching the corresponding StoreItemProduct
            $storeItemProduct = StoreItemProduct::findOrFail($id);
            event(new StoreViewItemProductLabelEvent($storeItemProduct, $request->all()));
        }
    }
    
    Login or Signup to reply.
  2. I think you could just add Log::debug(print_r($all_ids, true)). Then you could check it in laravel.log.

    Login or Signup to reply.
  3. You should check your routes, is the url going to your viewAllProductInfo function?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search