2025-04-28 16:15:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2025-04-28 16:45:23 +08:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2025-04-28 16:15:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 项目表
|
|
|
|
|
*/
|
|
|
|
|
class ProjectModal extends Model
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
protected $table = 'projects';
|
|
|
|
|
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
2025-04-28 16:45:23 +08:00
|
|
|
/**
|
|
|
|
|
* 用户关联
|
|
|
|
|
* @return HasOne
|
|
|
|
|
*/
|
|
|
|
|
public function user(): HasOne
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(UserModal::class, 'id', 'user_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 作者关联
|
|
|
|
|
* @return HasOne
|
|
|
|
|
*/
|
|
|
|
|
public function author(): HasOne
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(UserModal::class, 'id', 'author_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 标签关联
|
|
|
|
|
* @return BelongsToMany
|
|
|
|
|
*/
|
|
|
|
|
public function labels(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(LabelModal::class, 'project_labels_relations', 'project_id', 'label_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 截图关联
|
|
|
|
|
* @return HasMany
|
|
|
|
|
*/
|
|
|
|
|
public function screenshots(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(ScreenshotModal::class, 'project_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 框架关联
|
|
|
|
|
* @return BelongsToMany
|
|
|
|
|
*/
|
|
|
|
|
public function frameworks(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(FrameworkModal::class, 'project_frameworks_relations', 'project_id', 'framework_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 技术栈关联
|
|
|
|
|
* @return BelongsToMany
|
|
|
|
|
*/
|
|
|
|
|
public function technologyStacks(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(TechnologyStackModal::class, 'project_technology_stacks_relations', 'project_id', 'technology_stack_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能关联
|
|
|
|
|
* @return HasMany
|
|
|
|
|
*/
|
|
|
|
|
public function features(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(FeatureModal::class, 'project_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分类关联
|
|
|
|
|
* @return HasOne
|
|
|
|
|
*/
|
|
|
|
|
public function category(): HasOne
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(CategoryModal::class, 'id', 'category_id');
|
|
|
|
|
}
|
2025-04-28 16:15:09 +08:00
|
|
|
}
|