Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alexhiggins's avatar

dd Input::get()

It will be Input::get('profile.fullname')

theUnforgiven's avatar

Tried that also

  $profile->fullname = Input::get('profile.fullname');
  $profile->save();

But saves as empty field.

theUnforgiven's avatar

Also tried

Input::get('profile[fullname]');

Which is what is in the form but that doesn't work either, am I missing something here?

theUnforgiven's avatar

If i do

 dd($input['profile']);

It returns:

array (size=3)
  'fullname' => string 'John Doe' (length=11)
  'email' => string 'john@example.com' (length=19)
  'company_name' => string 'Acme' (length=8)

So how can i get the fullname in the Input::get(); ?

leitom's avatar

Just do $profile = Input::get('profile'); then all info will be stored in the array $profile

theUnforgiven's avatar

As i need to grab the input from this

<div class="form-group">
             <div class="col-sm-2">Full Name</div>
                 <div class="col-lg-5">
                    {{ Form::text('profile[fullname]', Input::old('profile[fullname]'), array('class'=>'form-control')) }}
                 </div>
        </div>

so i can save/update the DB when a user updates their full name.

theUnforgiven's avatar
$profileInput = Input::get('profile');
$profile->fullname = $profileInput['fullname'];

$profile->save();

Still saves as blank/empty

leitom's avatar

How are you getting $profile? Like $user->profile()?

theUnforgiven's avatar

I fixed it, had a Homer Simpson moment I put the $profile->save(); inside of the if input has file statement. So all working fine and dandy now :)

andreportaro's avatar

Hey guys. I dont know if the issue has been solved, but for me what solved was to realize Laravels 5.2 lazy loading.

That means that the relationship will only be accessed when requested.

If I tried that, it wouldnt work:

  {!! Form::label('info[menor_km_possivel]','Menor KM possível') !!}
  {!! Form::text('info[menor_km_possivel]',null,['class'=>'form-control']) !!}

But if I echoed the value first, then the form helper would load the input with the value:

  {{ $destino->info->menor_km_possivel }} // 40
  {!! Form::text('info[menor_km_possivel]',null,['class'=>'form-control']) !!}

Then, reading from [https://laravel.com/docs/master/eloquent-relationships#eager-loading Eloquent Docs], I realized we have to explicitly load the relationship:

    public function edit($id){

        $destino = Destino::with('info')->findOrFail($id);

        return view('admin.destinos.edit', compact('destino'));
    }
```

Then it worked.
Previous

Please or to participate in this conversation.