I try to let my users update their ads and after click on update button i will get this error:
ErrorException in AdController.php line 108:
Creating default object from empty value
my AdController
line 108
is:
$ad->company_id = Input::get('company_id');
And here is the refer line to that code in my form: as you can see company_id
field is not empty and will pass company id
number to that field which is the same as store
method and works perfectly in there but for update
method returns this error, also when I check my page source codes there is correct company id and isn't empty.
{!! Form::model($ads, ['route' => ['company.update', $ads->id], 'method' => "PUT", 'files' => true]) !!}
<input type="hidden" name="company_id" value ="@foreach ($companies as $company){{ $company->id }}@endforeach">
//the rest of the codes
{!! Form::close() !!}
any idea why is that?