mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Http\Helpers\Hasher;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
class EntitySignature extends Model
|
|
{
|
|
protected $table = 'entity_signatures';
|
|
|
|
protected $appends = [
|
|
'hash_id',
|
|
'entity_hash_id',
|
|
'entity_list'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'id',
|
|
'entity_id',
|
|
];
|
|
|
|
public function entity()
|
|
{
|
|
return $this->belongsTo('App\Models\Entity', 'entity_id');
|
|
}
|
|
|
|
public function getHashIdAttribute()
|
|
{
|
|
return Hasher::encode('entity_signatures', $this->id);
|
|
}
|
|
|
|
public function getEntityHashIdAttribute()
|
|
{
|
|
return Hasher::encode('entities', $this->entity_id);
|
|
}
|
|
|
|
public function getEntityListAttribute()
|
|
{
|
|
return $this->entity()->get()->makeHidden(['entity_signature_list']);
|
|
}
|
|
|
|
public function getUpdatedAtAttribute($date)
|
|
{
|
|
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
|
}
|
|
|
|
public function getCreatedAtAttribute($date)
|
|
{
|
|
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
|
}
|
|
}
|