Reputation: 147
I have the following controller, passing this array of information to my view
public function index ()
{
public function index ()
{
$ information = [
'nroclients' => '10',
'nroservices' => '20',
'nrousuers' => '30',
'nroordensservices' => '40',
];
return view ('dashboard.index', compact ('information'));
}
}
how can I access each element separately? index.blade.php
number of clients: {{information-> nroclients}} <br>
number of services: {{information-> nroservices}}
Does this run in my view should not work?
The reported error is
(2/2) ErrorException Trying to get property of non-object (View: C: \ wamp64 \ www \ sistemtest \ resources \ views \ panel \ index.blade.php)
Upvotes: 1
Views: 2369
Reputation: 7420
Its an array not an object or json so you should access keys like this in blade:
{{$information['nroclients']}}
instead of
number of clients: {{information-> nroclients}}
Upvotes: 4