【发布时间】:2021-01-30 14:33:43
【问题描述】:
我的表中有字符串列,它应该存储唯一的标记,但它存储的是这样的:
??6?i!a\????5?&?9?
代码
controller
use Illuminate\Support\Str;
public function store(Request $request)
{
$recipient = new RsvpPerson;
$recipient->token = Str::random(20);
$recipient->save();
}
Schema
Schema::create('rsvp_people', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('token')->unique();
$table->timestamps();
}
有什么想法吗?
【问题讨论】:
-
@KamleshPaul 是的,字母和数字的混合,大写与否……
-
@KamleshPaul 我想我必须安装帮助程序包(现在试试...)stackoverflow.com/a/58163479/8490993
-
使用 laravel 7,显然他们已将其从默认设置中删除
-
好像已经有了,那为什么不行呢?!
-
echo Illuminate\Support\Str::random(10);返回什么?