Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
cómo pasar datos provenientes de la consulta laravel como un objeto json a la función en javascript

De hecho, estoy usando gráficos en mi proyecto para el cual estoy pasando datos dinámicos del controlador a la cuchilla y luego en el script js. La función js en la hoja acepta la matriz de objetos y no sé cómo asignar los datos del controlador a esa función js.

 $data['typesBasedProperties'] = DB::table('properties') ->join('property_types', 'properties.property_type', 'property_types.id') ->select('property_types.types as label', DB::Raw('COUNT(properties.id) as value')) ->whereIn('properties.id', $property_ids) ->groupBy('label') ->get() ->toJson();

y esta es la funcion js

 var donutChart = function(){ Morris.Donut({ element: 'morris_donught', data: [ { label: " Download Sales ", value: 12, }, { label: " In-Store Sales ", value: 30 }, { label: " Mail-Order Sales ", value: 20 } ], resize: true, redraw: true, colors: ['#2b98d6', 'rgb(59, 76, 184)', '#37d159'], //responsive:true, }); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que tienes que hacer algo como esto:

 <script> var typesBasedProperties = {!! $typesBasedProperties !!} </script>

Después de esto, tiene el objeto typesBasedProperties disponible en todo su código js.

Consulte la documentación de laravel para obtener más información.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!