I'm working with blade laravel, I need to access the internal elements of an array that I return to my view from the controller, this is the result when I make a dd [! [Arrangement] [1]] [1]
I'm working with blade laravel, I need to access the internal elements of an array that I return to my view from the controller, this is the result when I make a dd [! [Arrangement] [1]] [1]
What I imagine you have done is to ask by debugging dd () to your variable from the controller. And what you want, is to access the data of that arrangement from the views if I have not interpreted wrongly. It is true that the question leaves to be desired, however, I give you a quick response.
There are several ways / methods of passing data to views. I explain 2 and the rest in the documentation, I would recommend you take a look.
When you return to your controller in sight, you can do
Return view('carpeta.plantilla', compact('array,objeto,array2,objeto2'));
In this first form, you can pass as many arrangements as you wish, although generally, if it is an array or simple arrangement I recommend using the second option.
With the first option, for example, you could do a "query of database entries in your controller", store the query or object directly in a variable and pass it through compact.
Then in your views, just do
@foreach($objeto as $obj)
{{ $obj->id }}
@endforeach
Accessing each object in each round, and its id within it.
As a second option you can use "With"
return view('carpeta.plantilla')->with($array);
And the reason why I recommended using the with for simple arrays and / or associative, is because from the views, you can access the values of the array directly.
For example if you have
$array = ['parametro1' => 'grande', 'parametro2' => 'pequeño'];
return view('carpeta.plantilla')->with($array);
And in your views you just have to put:
{{$ parameter1}} And you would automatically access the value of the array you passed with with.
Let's say what he does with, is "save variables accessible to the view"
My recommendation is 1st think as you want or you will show your data in the views and what use you will give them. The second step, go to the documentation and see what other different ways you could use and choose the one that best suits your logic and load it.
I hope it helps you.
Greetings!