jericopulvera's avatar

How to save enum data in a column that uses enum data type?

// I have this enum column
$table->enum('color', ['blue','red']);

and I'm saving it like this
$color = 'blue';

Product::create([
    'color' => $color,
]);

// it produces this error.
QueryException in Connection.php line 647:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'color' at row 1
0 likes
1 reply
xsme's avatar
xsme
Best Answer
Level 2

Correct this:

['blue'red']

To

['blue','red']

Please or to participate in this conversation.