我正在尝试为inventories使用此迁移创建的表运行迁移:
Schema::create('inventories', function (Blueprint $table) {
$table->increments('id');
$table->integer('remote_id')->unsigned();
$table->integer('local_id')->unsigned();
$table->string('local_type');
$table->string('url')->nullable()->unique();
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试添加运行迁移,我在表中添加了一个外键:
Schema::table('inventories', function (Blueprint $table) {
$table->foreign('local_id')->references('id')->on('contents')->onDelete('cascade');
});
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行迁移时出现错误:
[Illuminate\Database\QueryException]
SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败(middleton
.#sql-5d6_162a,CONSTRAINTinventories_local_id_foreignFOREIGN KEY(local_id)REFERENCEScontents(id)ON DELETE CASCADE)(SQL:alter table 在删除级联上inventories添加约束inventories_local_id_foreign外键(local_id)引用contents(id))Run Code Online (Sandbox Code Playgroud)Schema::create('inventories', function (Blueprint $table) { $table->increments('id'); $table->integer('remote_id')->unsigned(); $table->integer('local_id')->unsigned(); $table->string('local_type'); $table->string('url')->nullable()->unique(); $table->timestamps(); });SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败(
middleton
.#sql-5d6_162a,CONSTRAINTinventories_local_id_foreignFOREIGN KEY(local_id)REFERENCEScontents(id …
我\xc2\xb4m开始我的Livewire之旅,并创建了一个列表组件,其中包含每个列表元素的表单组件,当我试图使其全部工作时,我不断收到以下从未见过的异常:
\n\n\nLogicException 不支持对具有多个模型连接的集合\n进行排队。
\n
我对项目中的每个模型使用相同的单个连接,并且我没有在我当前正在工作的任何组件中故意排队任何内容,因此我不知道从哪里开始调试此异常。错误消息也没有多大帮助。事实上,我什至不知道要在这里发布什么内容来让你们帮助我,而不是发布整个项目......我想我只是在寻找任何关于从哪里开始寻找的线索解决这个问题,所以非常感谢任何帮助。
\n这是错误消息堆栈跟踪:
\n\n\nC:\\Users\\bfcba\\OneDrive\\aplicaciones\\duki\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Collection.php:705
\n
public function getQueueableConnection()\n{\n if ($this->isEmpty()) {\n return;\n }\n\n $connection = $this->first()->getConnectionName();\n\n $this->each(function ($model) use ($connection) {\n if ($model->getConnectionName() !== $connection) {\n throw new LogicException(\'Queueing collections with multiple model connections is not supported.\');\n }\n });\n\n return $connection;\n}\nRun Code Online (Sandbox Code Playgroud)\n我\xc2\xb4很乐意发布您认为必要的所有信息。请告诉我。
\n提前致谢。
\n我正在寻找一些解决方案,帮助从带有突出显示功能的 html 字符串中搜索术语。我可以通过从字符串中删除 html 内容来做到这一点。但问题是我将无法看到它突出显示的原始内容。我确实有以下功能,可以在没有 html 标记的情况下搜索和突出显示字符串。
private static updateFilterHTMLValue(value: string, filterText: string): string
{
if (value == null) {
return value;
}
let filterIndex: number = value.toLowerCase().indexOf(filterText);
if (filterIndex < 0) {
return null;
}
return value.substr(0, filterIndex)
+ "<span class='search-highlight'>"
+ value.substr(filterIndex, filterText.length)
+ "</span>"
+ value.substr(filterIndex + filterText.length, value.length - (filterIndex + filterText.length));
}
Run Code Online (Sandbox Code Playgroud)
因此,为了管理使用 html 对字符串的搜索,我创建了可以使用 html 搜索字符串的新函数。(我在搜索正确的字符串匹配之前删除了 html 部分)
private static test(value: string, filterText: string): string {
if (value == null) {
return value;
} …Run Code Online (Sandbox Code Playgroud)