generated from liutk/owl-admin-base
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use EloquentFilter\Filterable;
|
|
|
|
class PersonChange extends Model
|
|
{
|
|
use HasFactory;
|
|
use Filterable;
|
|
|
|
public const TYPE_IN = 1; //迁入
|
|
public const TYPE_BIRTH = 2; //出生
|
|
public const TYPE_OUT = 3; //迁出
|
|
public const TYPE_DIE = 4; //死亡
|
|
public const TYPE_MERGE = 5; //合户
|
|
public const TYPE_SPLIT = 6; //分户
|
|
public const TYPE_MIGRATE = 7; //迁移
|
|
public const TYPE_CHANGE = 8; //变更户主
|
|
|
|
protected $fillable = ['person_id', 'type', 'changed_at', 'reason', 'old_master', 'new_master', 'phone', 'extends', 'extends_mark', 'remark'];
|
|
|
|
protected $casts = [
|
|
'extends' => 'array',
|
|
];
|
|
|
|
public function scopeSort($q)
|
|
{
|
|
$q->orderBy('changed_at', 'desc')->orderBy('created_at', 'desc');
|
|
}
|
|
|
|
public static function typeMap()
|
|
{
|
|
return [
|
|
self::TYPE_IN =>'迁入',
|
|
self::TYPE_BIRTH =>'出生',
|
|
self::TYPE_OUT =>'迁出',
|
|
self::TYPE_DIE =>'死亡',
|
|
self::TYPE_MERGE =>'合户',
|
|
self::TYPE_SPLIT =>'分户',
|
|
self::TYPE_MIGRATE =>'迁移',
|
|
self::TYPE_CHANGE =>'变更户主',
|
|
];
|
|
}
|
|
|
|
protected function serializeDate(\DateTimeInterface $date)
|
|
{
|
|
return $date->format('Y-m-d H:i:s');
|
|
}
|
|
|
|
public function person()
|
|
{
|
|
return $this->belongsTo(Person::class, 'person_id');
|
|
}
|
|
}
|