Receive Array in Controller Laravel

0

When I pick up the form values in the controller, I skip the null and I do not know why

 <body>
            <form action="FormTablaJuego" method="POST">
                {!! csrf_field(); !!}
                @for($i=0;$i<11;$i++) 
                 {!! \Session::get('num'); !!} * {!! $i !!} = <input type='text' name='caja[]' value=''><br/>
                @endfor
                <input type='submit' value='Comprobar' name="btncomprobar"><br/>
                <input type='submit' value='Rendirse' name="btnrendirse"><br/>
            </form>
         </body>

On the route:

Route::post('FormTablaJuego' ,'EduController@jugar');

On the controller:

 public function jugar(Request $request)
    {
        echo var_dump($request->get('caja[]'));
    }

I show it in the controller to know what is correct before continuing. But it returns NULL

    
asked by EduBw 09.11.2017 в 10:22
source

2 answers

2

You do not have to put the "[]" is simply $request->get('caja') or $request->caja

    
answered by 09.11.2017 / 12:10
source
-1

Laravel offers a better way to print data on screen and is using dd() , you should use it instead of echo and var_dump() .

You should do a dd($request->all()) so you can verify that the controller is receiving your data and how you are receiving it, once you verify this you could do a dd($request->get('caja')) since I would believe that is how you should receive it .

    
answered by 09.11.2017 в 14:27