香洲二院小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
mini_xzey/app/Models/Admin/Department.php

81 lines
1.6 KiB

<?php
declare(strict_types=1);
namespace App\Models\Admin;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Department extends Model
{
use HasFactory;
/**
* @var string
*/
protected $connection = 'mysql_admin';
/**
* @var string
*/
protected $table = 'departments';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'dept_id',
'dept_name',
'category_id',
'building_id',
'dept_location',
'icon',
'introduction',
'sort',
'is_enable'
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'id' => 'integer',
'category_id' => 'integer',
'sort' => 'integer',
'is_enable' => 'integer',
];
/**
* 科室分类
* @return BelongsTo
*/
public function departmentCategory(): BelongsTo
{
return $this->belongsTo(DepartmentCategory::class, 'category_id');
}
/**
* 获取科室医生
* @return HasMany
*/
public function doctor(): HasMany
{
return $this->hasMany(Doctor::class, 'dept_id', 'dept_id');
}
/**
* 获取楼群信息
* @return BelongsTo
*/
public function buildingDistribution(): BelongsTo
{
return $this->belongsTo(BuildingDistribution::class, 'building_id');
}
}