How to obtain specific data from an array that is stored in a Session in Laravel 5.1?

1

Greetings guys, the topic is simple I need to show in a view the data of an array that is in session, which contains several arrays.

What I am doing is the following:

This is how I update the array:

public function inscribir(Evento $evento, Request $request){
    $tienda = \Session::get('tienda');
    $inscrito = [            
        'nombre'=>$request->get('nombre'),            
        'edad'=>$request->get('edad'),
        'cedula'=>$request->get('cedula'),
        ];
    $tienda[$inscrito['cedula']] = $inscrito;
    \Session::put('tienda', $tienda);

    //dd(\Session::get('tienda'));
    return view('tienda.inscribir', compact('tienda'));


}

Thus I send it to the view:

public function index()
{
    $tienda = \Session::get('tienda');
   // dd(\Session::get('tienda'));
    return view('tienda.tienda', compact('tienda'));
}

and so I try to show it:

@foreach($tienda as $inscrito)

                    @foreach($inscrito as $value)
                    <td> {{ $value }} </td>
                    @endforeach

                @endforeach

It is showing me the whole array in the view, but what I need is to go through each array and show the specific data, here is the image of what is being seen as an example with dd.

    
asked by Susje 08.07.2017 в 14:38
source

1 answer

1

I already found a way to show it in the view, in the following way:

@foreach($tienda as $inscrito)
            <tr>                    
                <td>{{ $inscrito['nombre'] }}</td>
                <td>{{ $inscrito['cedula'] }}</td>
                <td>{{ $inscrito['edad'] }} </td>
            </tr>                       
@endforeach

I could almost swear that I had already tried it.

    
answered by 08.07.2017 / 15:10
source