mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
entity signature api
This commit is contained in:
+11
-1
@@ -11,13 +11,23 @@ class Entity extends Model
|
||||
{
|
||||
protected $table = 'entities';
|
||||
|
||||
protected $appends = ['hash_id'];
|
||||
protected $appends = ['hash_id', 'entity_signature_list'];
|
||||
|
||||
public function entity_signature()
|
||||
{
|
||||
return $this->hasMany('App\Models\EntitySignature', 'entity_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('entities', $this->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') : '';
|
||||
|
||||
@@ -2,10 +2,39 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class EntitySignature extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'entity_signatures';
|
||||
|
||||
protected $appends = ['hash_id', 'entity_list'];
|
||||
|
||||
public function entity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Entity', 'entity_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('entity_signatures', $this->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') : '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user