Access collection instance as javascript variable? - development

Access collection instance as javascript variable?

I was trying to send collection of following Query:

 $monthly_report_chart = DB::table("transactions")
        ->select(DB::raw("Date(updated_at) as today"),DB::raw("SUM(collected_today) as sum"))
        ->groupBy(DB::raw('Date(updated_at)'))
        ->where(DB::raw('Month(updated_at)'),'=',$month)
        ->get();

And i want to access the collection in javascript like this :

{!! json_encode($monthly_report_chart->today) !!}

But it throws following Error :

Property [today] does not exist on this collection instance

How do access collection instance in javascript?
Thanks!



from Laravel Questions and Answers https://laravelquestions.com/php/access-collection-instance-as-javascript-variable/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

ng-include of inline SVG does not display gradient except in Chrome

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development