我正在尝试对同items
一张表使用两个不同的类别模型。
我有3个模型
系统类别
Schema::create('system_categories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->timestamps();
});
用户类别
Schema::create('user_categories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->integer('user_id');
$table->timestamps();
});
物品
Schema::create('items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->integer('categoryable_id');
$table->string('categoryable_type');
$table->timestamps();
});
项目类别可以是来自system_categories
或user_categories
表
我看到了一些多态关系,但它是关于两个不同的模型如何属于一个类别,而不是关于模型如何属于两个不同的类别模型
谢谢。