Laravel 字符串数据,右截断:1406 列数据太长

Laravel string data, right truncated: 1406 Data too long for column

我有 pivot table post_tags 它将存储 post 的 id 和标签的 id

PS: 我所有的 table 都使用 uuid

现在,当我尝试 add/change 我的 post 标签更新功能时 returns 这个错误:

message: "SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'tag_id' at row 1 (SQL: insert into `post_tags` (`id`, `post_id`, `tag_id`) values (d0fb529e-38ac-4197-9455-e41898de9d05, c4a41a90-1274-4830-8974-71d6b5834216, bd89cf45-bb85-4e4b-93f8-342e86dbaa31,9adc54df-e778-432d-be25-282169a7c5af))"

代码

//.....
$post->save();
$tags_id = (array) $request->input('tags');
foreach( $tags_id as $tag_id ) {
  $tag_data_to_sync[ $tag_id ] = [ 'id' => \Ramsey\Uuid\Uuid::uuid4()->toString() ];
}
$post->tags()->sync( $tag_data_to_sync );

有什么想法吗?

已解决

我的标签 ID 像 "86198680-1f0b-4544-851a-4c39e4f7c3ec,2bbe9776-7413-43fa-9cae-3378f39f3c2d" 一样,我不得不分解我的标签数据才能循环播放它们

$tags_id = explode(',', $request->input('tags'));

现在工作正常。