Files
new_dqb_new/app/Models/Resume.php
2021-12-10 14:15:22 +08:00

88 lines
2.0 KiB
PHP

<?php
namespace App\Models;
use App\Models\Traits\HasOneCover;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Arr;
class Resume extends Model
{
use HasOneCover;
protected $casts = [
'information' => 'json'
];
/***
* Notes: 所属分类
*
* @Author: 玄尘
* @Date: 2021/12/1 9:57
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
/**
* Notes: 所属科室
*
* @Author: 玄尘
* @Date: 2021/12/1 9:58
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function group(): BelongsTo
{
return $this->belongsTo(ResumeGroup::class);
}
/**
* Notes: 跳转链接
*
* @Author: 玄尘
* @Date: 2021/12/1 13:11
* @return string
*/
public function getLinkAttribute(): string
{
return route('resume.show', $this);
}
/**
* Notes: 获取基础数据
*
* @Author: 玄尘
* @Date: 2021/12/1 13:11
* @param $key
* @param string $default
* @return array|\ArrayAccess|mixed
*/
public function getInformation($key, string $default = '')
{
return Arr::get($this->information, $key, $default);
}
/**
* Notes: 获取基本信息名称
*
* @Author: 玄尘
* @Date: 2021/12/1 15:53
*/
public function getInformationName($key): string
{
return [
'duty' => '职务',
'tenure' => '任期',
'rank' => '职称',
'education' => '学历',
'mobile' => '电话',
'email' => '电子邮件',
'address' => '通讯地址',
'part_job' => '学术兼职',
'direction' => '研究方向',
][$key] ?? '未知';
}
}