This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Caveat, I'm still learning so the object array may be perfectly fine with the issue being my completely lack of knowledge. I also have some OctoberCMS specific questions (maybe) involving twig. If those are unanswerable, that's fine. I'd still love an answer to the first part.
Anyway, I used Laravel's query builder to get an object array that prints the following:
array(2) {
[0]=> object(stdClass)#564 (2) {
["name"]=> string(10) "Debit Card"
["buys"]=> int(6)
}
[1]=> object(stdClass)#561 (2) {
["name"]=> string(12) "Gift Card"
["buys"]=> int(10)
}
}
I need to be able to get that information to a separate file so I can use High Charts to make a graph of the data. But I have no idea how to turn it into something usable. I tried to force it by doing something like foreach(myArray as myObject){ myObject = (array) myObject;}
but that didn't seem to do anything.
Is there a nice and convenient way to either use this data as is or turn it into an array of arrays?
Second question (OctoberCMS component stuff):
I'm having a hell of a time getting that information to the default.html
page to easily be assigned to a JS variable.
My work around was to create a single array for each object in the above output and do the whole $this->debit = $debit;
. But in order for me to get that to a javascript array, I have done the following which I cannot imagine is best practice.
var debitArray = [
`{{__SELF__.debit.name}}',
{{__SELF__.debit.buys}}
];
So now I have a javascript array in a usable format, but I've heard to try and leave twig out of your <script></script>
tags...
1-1 of 1