模型关系设置
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* 项目标签关联表
|
||||
@@ -13,4 +14,22 @@ class ProjectLabelRelationModal extends Model
|
||||
protected $table = 'project_label_relations';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* 项目
|
||||
* @return HasOne
|
||||
*/
|
||||
public function project(): HasOne
|
||||
{
|
||||
return $this->hasOne(ProjectModal::class, 'id', 'project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签
|
||||
* @return HasOne
|
||||
*/
|
||||
public function label(): HasOne
|
||||
{
|
||||
return $this->hasOne(LabelModal::class, 'id', 'label_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user