我得到了错误:
SQLSTATE [01000]:警告:1265列'level'的数据被截断了。.
我的猜测是Form :: select应该以不同的方式使用,如何?
// in my migration:
$table->enum('level', ['easy', 'hard']);
// in my controller Store function:
$tablee = new Tablee; // this is view file called Tablee.php
$tablee->level = $request->input('level');
$tablee->save();
// and part of my code in create.blade.php
<div class="form-group">
{{Form::label('level', 'Please choose level')}}
{{Form::select('level', ['easy' => 'easy', 'hard' => 'hard'], ['class' => 'form-control'])}}
</div>
答案 0 :(得分:0)
Form::select
的第三个参数是所选元素。
public function select($name, $list = [], $selected = null, $options = [])
所以您应该将自己的名字更改为
{{ Form::select('level', ['easy' => 'easy', 'hard' => 'hard'], null, ['class' => 'form-control']) }}