我正在尝试为 Laravel 迁移设置默认值。我正在使用 SQLite。
\n当我尝试插入一条包含分配了默认值的字段的记录时,返回错误: SQL 错误或缺少数据库(表客户没有名为国家/地区的列)
\n这是迁移脚本:
\nphp\nSchema::create(\'customers\', function (Blueprint $table) {\n $table->id();\n $table->string(\'name\');\n $table->string(\'contact_person_first_name\');\n $table->string(\'contact_person_name\');\n $table->string(\'contact_person_email_address\');\n $table->string(\'address\');\n $table->string(\'zipCode\');\n $table->string(\'city\');\n $table->string(\'country\')->default("BELGI\xc3\x8b");\n $table->string(\'vat_number\')->default("BE");\n $table->timestamps();\nRun Code Online (Sandbox Code Playgroud)\n控制器:
\nphp\nSchema::create(\'customers\', function (Blueprint $table) {\n $table->id();\n $table->string(\'name\');\n $table->string(\'contact_person_first_name\');\n $table->string(\'contact_person_name\');\n $table->string(\'contact_person_email_address\');\n $table->string(\'address\');\n $table->string(\'zipCode\');\n $table->string(\'city\');\n $table->string(\'country\')->default("BELGI\xc3\x8b");\n $table->string(\'vat_number\')->default("BE");\n $table->timestamps();\nRun Code Online (Sandbox Code Playgroud)\n请求:
\n * Store a newly created resource in storage.\n *\n * @param CreateCustomerRequest $request\n * @return \\Illuminate\\Http\\RedirectResponse\n */\n public function store(CreateCustomerRequest $request)\n {\n Customer::create($request->validated());\n return response()->redirectTo(\'/customers\');\n }\nRun Code Online (Sandbox Code Playgroud)\n\n … 我在数据库模式中添加了一个日期时间:
$table->dateTime('send_at')->nullable();
Run Code Online (Sandbox Code Playgroud)
我已将属性设置为播种器中的 Carbon 实例:
$invoice->send_at = Carbon::now();
Run Code Online (Sandbox Code Playgroud)
当我尝试获取控制器内属性的类型时,它返回一个字符串:
dd(gettype($data['invoices'][0]->send_at));
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?我如何确定它是一个 Carbon 对象而不是一个字符串?
我想在 setUp 方法中为测试中的所有请求设置标头,而不是单独对所有测试进行设置。
是否有捷径可寻?
所以例子:
$this->withHeaders([
'Authorization' => 'Bearer ' . $response['data']['token'],
'Accept' => 'application/json'
])
Run Code Online (Sandbox Code Playgroud)
到:
setUp(){
$this->setHeaders([
'Authorization' => 'Bearer ' . $response['data']['token'],
'Accept' => 'application/json'
]);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Tailwind css 在悬停时使 div 更宽。这可能吗?如何?
我已经尝试了以下但没有奏效:
class="w-1/3 hover:w-3/5"
Run Code Online (Sandbox Code Playgroud) When I hover over a navigation item, I want a span border color to be changed. The group-hover does nothing...
Is this just not implemented in Tailwindcss yet?
<a class="group px-4 py-2 hover:bg-white
hover:text-primary transition-colors duration-300
rounded-sm"
:href="route">
<span class="pb-1 border-b border-white group-hover:border-black">
<slot/>
</span>
</a>
Run Code Online (Sandbox Code Playgroud)
I obviously can do this by writing css like this, but tailwind should be able to do this, right?
a:hover span {
border-color: black;
}
Run Code Online (Sandbox Code Playgroud)