1

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)

0

1 Answer 1

4

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}}
Sign up to request clarification or add additional context in comments.

2 Comments

I'm waiting for the time to accept your response, do you know how I use a model without applying the use? for example $ Client = new App \ Models \ Dashboard \ Client;
errr... I really dont understand what are you saying. Could you please explain more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.