Home > Software design >  How to dump on Route api doesn't work Laravel
How to dump on Route api doesn't work Laravel

Time:01-20

I gonna tried to make a query on project Laravel with VueJs on front.

When i try to dump my variable, nothing nothing is happening.

I have this road on api.php:

Route::resource('users.options', OptionController::class)->only('index', 'show', 'update', 'store', 'destroy');

And it's my controller :

$options = Option::with([
            'status',
            'lot:id,number,price',
            'promoteur:id,name',
            'programme:id,name,id_city',
            'programme.city:id,name,zip_code'
        ])
        ->orderBy('id', 'desc')
        ->select("id", "id_user", "id_prospect", "id_option_status", "id_promoteur", "id_programme", 'id_lot', "prospect_firstname", "prospect_lastname", 'created_at', 'commission_amount_iad', 'commission_rate_iad')
        ->get();

dd($options);

when I go to the page where the data is normally displayed, nothing....

I specify that the query is good, it works, I just want to have the dd of this one. The questions is How to Dump on the route api.php

Thanks for help !

CodePudding user response:

Since your endpoint is on api.php, in vue you should point to:

https://www.url.com/api/users.options

Suggestion: change users.options to users/options

In your terminal, clean cache for routes after change routes (web or api):

php artisan route:clear
  • Go to your browser, open console (mouse right click, then Inspect.
  • Go to tab Network Click on your page, to call that endpoint
  • Search in Network if endpoint was called Click that row.
  • Now you can see what request was made, what payload was sent and what is the endpoint response.

CodePudding user response:

You can print using print_r($options); exit; so it stop the execution and print collection object.

  •  Tags:  
  • Related