mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 20:34:01 +00:00
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Http\Helpers\Hasher;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
class Entity extends Model
|
|
{
|
|
protected $table = 'entities';
|
|
|
|
protected $appends = [
|
|
'hash_id',
|
|
'user_id',
|
|
'entity_signature_list'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'id',
|
|
'user_id',
|
|
];
|
|
|
|
public function entity_signature()
|
|
{
|
|
return $this->hasMany('App\Models\EntitySignature', 'entity_id');
|
|
}
|
|
|
|
public function getHashIdAttribute()
|
|
{
|
|
return Hasher::encode('entities', $this->id);
|
|
}
|
|
|
|
public function getUserHashIdAttribute()
|
|
{
|
|
return Hasher::encode('users', $this->user_id);
|
|
}
|
|
|
|
public function getEntitySignatureListAttribute()
|
|
{
|
|
return $this->entity_signature()->get()->makeHidden(['entity_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') : '';
|
|
}
|
|
}
|