46 lines
871 B
PHP
46 lines
871 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
/**
|
|
* 用户表
|
|
*/
|
|
class UserModal extends Model
|
|
{
|
|
//
|
|
protected $table = 'users';
|
|
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* 项目关联 - 上传视角
|
|
* @return HasMany
|
|
*/
|
|
public function projects(): HasMany
|
|
{
|
|
return $this->hasMany(ProjectModal::class, 'user_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 项目关联 - 作者视角
|
|
* @return HasMany
|
|
*/
|
|
public function projectsAuthor(): HasMany
|
|
{
|
|
return $this->hasMany(ProjectModal::class, 'author_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 角色关联
|
|
* @return HasOne
|
|
*/
|
|
public function roles(): HasOne
|
|
{
|
|
return $this->hasOne(RoleModal::class, 'id', 'role_id');
|
|
}
|
|
}
|