我收到以下错误代码
从空值创建默认对象
当我转储$ post时,它返回null,但是当我转储$ id时,它返回ID。
控制器代码如下:
{!! Form::model('Customers', ['route'=>['products.update', Auth::user()->id],'method' => 'PUT']) !!}
{{ Form::hidden('business', Auth::user()->name, array('class' => 'form-control', 'required' => '','maxlength'=>'255'))}}
{{ Form::label('post', 'Mailbox')}}
{{ Form::checkbox('post',1, 0, array('class' => 'form-control'))}}
<div id="extra_form">
{{ Form::label('mailbox', 'Mailbox Option')}}</br>
{{ Form::select('mailbox', array('rolling' => 'Rolling','month' => 'Monthly','year' => 'Yearly'), 'null', array('class' => 'form-control'))}}
</div>
{{ Form::label('conum', 'Company Number')}}
{{ Form::checkbox('conum',1, 0, array('class' => 'form-control'))}}
<div id="extra_form1">
{{ Form::label('prefix', 'Preferred number prefix')}}
{{ Form::tel('prefix', 0, array('class' => 'form-control'))}}
</div>
{{ Form::label('telans', 'Telephone Answering')}}
{{ Form::checkbox('telans',1, 0, array('class' => 'form-control'))}}
<hr>
<div id="extra_form3">
{{ Form::label('posttc', 'Mailbox Terms and Conditions')}}</br>
Click here
</div>
<div id="extra_form2">
{{ Form::label('conumtc', 'Company Number Terms and Conditions')}}</br>
Click here
</div>
<div id="extra_form4">
{{ Form::label('telanstc', 'Telephone Answering Terms and Conditions')}}</br>
Click here
</div>-->
{{ Form::label('TC', 'I accept the Office Flex terms and conditions.')}}
{{ Form::checkbox('TC',1, 0, array('class' => 'form-control','required'=>''))}}
{{ Form::submit('Select Product', array('class' => 'btn btn-success', 'id' => 'create_btn'))}}
{!! Form::close() !!}
索引文件中的表单如下
Thread
答案 0 :(得分:0)
我添加了以下代码以确保添加了正确的表ID。
$id = DB::table('customers')->where('business', Auth::user()->name)->pluck('id');
$iid=implode($id);