如何在laravel 5.2

时间:2016-05-10 10:27:48

标签: laravel-5

generaljournal.blade.php

 <div class="form-group">
                    {!!Form::label('Account Type','Account Type',array('class'=>'col-sm-2 control-label'))!!}
                    <div class="col-sm-10">
                    {!!Form::select('size', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}
                    </div>
                    </div>

GeneralController.php

public function store(Request $request)
    {
        //
         $Generals = new General;
        $Generals->Line_No = $request->Line_No;
        $Generals->Posting_Date = $request->Posting_Date;
        $Generals->Document_No= $request->Document_No;
        $Generals->Account_Type = $request->Account_Type;
        $Generals->save(); 

        return redirect()->action('GeneralController@index');
    }

错误

  

Connection.php第673行中的QueryException:SQLSTATE [23000]:完整性   约束违规:1048栏&#39; Account_Type&#39;不能为null(SQL:   插入general journalLine_NoPosting_Date,   Document_NoAccount_Type)值(6000,20 / 05/2016,Doc0001 ,,))

我在account_type上收到一个错误,其值应该是下拉列表中的一个选项。有人请帮助我成为laravel的新人

1 个答案:

答案 0 :(得分:0)

刀片中没有名称为Account_Type的元素。 尝试更改此

{!!Form::select('size', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}

到这个

{!!Form::select('Account_Type', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}