模型关系设置
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 分类表
|
||||
@@ -13,4 +14,13 @@ class CategoryModal extends Model
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* 项目
|
||||
* @return HasMany
|
||||
*/
|
||||
public function projects(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProjectModal::class, 'category_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user