Laravel Laravel 5.8 中的 mysql 集体下拉

Laravel Collective drop-down to mysql in Laravel 5.8

我收到错误:

SQLSTATE[01000]: Warning: 1265 Data truncated for column '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>

Form::select的第三个参数是被选元素。

public function select($name, $list = [], $selected = null, $options = [])

所以你应该把你的改成

{{ Form::select('level', ['easy' => 'easy', 'hard' => 'hard'], null, ['class' => 'form-control']) }}