改版
This commit is contained in:
@@ -14,10 +14,12 @@ class Category extends Model
|
||||
public const TYPE_SHOW = 'show';
|
||||
public const TYPE_ARTICLE = 'article';
|
||||
public const TYPE_ADVERT = 'advert';
|
||||
public const TYPE_PERSON = 'person';
|
||||
public const TYPES = [
|
||||
self::TYPE_ARTICLE => '文章列表',
|
||||
self::TYPE_SHOW => '文章详情',
|
||||
self::TYPE_ADVERT => '图片',
|
||||
self::TYPE_PERSON => '简历',
|
||||
];
|
||||
|
||||
public function getLinkAttribute()
|
||||
@@ -27,6 +29,7 @@ class Category extends Model
|
||||
|
||||
/**
|
||||
* 关联的数据
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function relations()
|
||||
@@ -41,6 +44,9 @@ class Category extends Model
|
||||
case self::TYPE_ADVERT:
|
||||
return $this->hasMany(Advert::class);
|
||||
break;
|
||||
case self::TYPE_PERSON:
|
||||
return $this->hasMany(Resume::class);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -63,6 +69,7 @@ class Category extends Model
|
||||
|
||||
/**
|
||||
* Notes: 获取当前分类及子分类ID
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2020/4/6 3:12 下午
|
||||
* @return array
|
||||
|
||||
65
app/Models/Resume.php
Normal file
65
app/Models/Resume.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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
|
||||
*/
|
||||
public function getInformation($key, string $default = '')
|
||||
{
|
||||
return Arr::get($this->information, $key, $default);
|
||||
}
|
||||
}
|
||||
8
app/Models/ResumeGroup.php
Normal file
8
app/Models/ResumeGroup.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class ResumeGroup extends Model
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user