Laravel 5 getting input values that are arrays

Tartar picture Tartar · Jun 14, 2015 · Viewed 28k times · Source

I have a text field like

{!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!}

In my form. And when I try to get its value in my controller but it comes null. What I try is

$adress = Request::get('representive.0.address_1');

I also tried some other ways but could not end up with a proper solution. How can I get the value of this field? Any help would be appreciated.

Answer

Bogdan picture Bogdan · Jun 14, 2015

The Request::get() method is implemented by Symfony\Component\HttpFoundation\Request which the Illuminate\Http\Request class extends. This method does not parse the string parameter passed using the dot notation as Laravel does. You should instead be using the Request::input which does:

$adress = Request::input('representive.address_1');

As an alternative you can also use the Input facade and do Input::get().