php - foreach over object array not working properly -
I am using charts, JS by DWX (click to find documentation link) I also use Laravel Framework I want to generate some JQuery on the server side to output the graph I want For some reasons my project loop does not work, i get the following error: Invalid argument for my question is two times: 1. Why does not this work? 2. Will this code work in any way to generate names and values in jquery? Code: In the controller, here's how $ json_micromarket_participants are set up, I think that's fine ... After This is not working because you have encoded $ micromarket_participants in json, it's a Create a string, not an array. I think $ micromarket_participants, in this case, is the category of the object, so you should use this with just keeping in mind: $ json_micromarket_participants passing a the object's range (database query Rows from) that are json_encoded in my controller Each object has
Home_name and
Average_Occupancy property.
foreach ()
@section ('content') & lt; Script type = "text / javascript" & gt; Var chart datasource = {{$ json_micromarket_participants}}; $ {Function () {$ ("# chartContainer") dxChart ({Data Source: ChartDataSource, commonSeriesSettings: {argumentField: 'Home_name'}, series: [@foreach ($ json_micromarket_participants as $ micromarket_participant) {name: {{$ micromarket_participant- & gt; Home_name}} ', valueField:' {{$ micromarket_participant- & gt; Average_Occupancy}} '}, @endforeach]})}}) & lt; / Script & gt; & Lt; Div id = "chartcontainer" style = "max-width: 700px; height: 300px;" & Gt; & Lt; / Div & gt; @stop
$ Micromarket_participants = DB :: table ('home') - & gt; Select (array ('*', db :: raw ('' .QQ) ('' .exe. '' - `Eastx`, 2) + Pau ('Northings.' 'Northings, 2) AS distance') )) - & gt; Having ('distance', '& lt;', $ micromarket_size) - & gt; get(); $ Json_micromarket_participants = json_encode ($ micromarket_participants);
< code> @foreach ($ micromarket_participants $ as Micromarket_participant)
प्रोग्रामर के लिए php स्क्रिप्टिंग कोड
ReplyDeleteशब्दों को वाक्य लिपि में गिनें