mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Http\Helpers\Hasher;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
class ContractTemplateObligationDependency extends Model
|
|
{
|
|
protected $table = 'contract_template_obligation_dependencies';
|
|
|
|
protected $appends = [
|
|
'hash_id',
|
|
'user_hash_id',
|
|
'contract_template_obligation_hash_id',
|
|
'depend_contract_template_obligation_hash_id',
|
|
'contract_template_obligation_list',
|
|
'depend_contract_template_obligation_list'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'id',
|
|
'user_id',
|
|
'contract_template_obligation_id',
|
|
'depend_contract_template_obligation_id'
|
|
];
|
|
|
|
public function contract_template_obligation()
|
|
{
|
|
return $this->belongsTo('App\Models\ContractTemplateObligation', 'contract_template_obligation_id');
|
|
}
|
|
|
|
public function depend_contract_template_obligation()
|
|
{
|
|
return $this->belongsTo('App\Models\ContractTemplateObligation', 'depend_contract_template_obligation_id');
|
|
}
|
|
|
|
public function getHashIdAttribute()
|
|
{
|
|
return Hasher::encode('contract_template_obligation_dependencies', $this->id);
|
|
}
|
|
|
|
public function getUserHashIdAttribute()
|
|
{
|
|
return Hasher::encode('users', $this->user_id);
|
|
}
|
|
|
|
public function getContractTemplateObligationHashIdAttribute()
|
|
{
|
|
return Hasher::encode('contract_template_obligations', $this->contract_template_obligation_id);
|
|
}
|
|
|
|
public function getDependContractTemplateObligationHashIdAttribute()
|
|
{
|
|
return Hasher::encode('contract_template_obligations', $this->depend_contract_template_obligation_id);
|
|
}
|
|
|
|
public function getContractTemplateObligationListAttribute()
|
|
{
|
|
return $this->contract_template_obligation()->get()->makeHidden(['contract_template_obligation_dependency_list']);
|
|
}
|
|
|
|
public function getDependContractTemplateObligationListAttribute()
|
|
{
|
|
return $this->depend_contract_template_obligation()->get()->makeHidden(['contract_template_obligation_dependency_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') : '';
|
|
}
|
|
}
|