mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
contract active api
This commit is contained in:
@@ -16,11 +16,12 @@ class ContractObligation extends Model
|
||||
'contract_list',
|
||||
'contract_obligation_dependency_list',
|
||||
'depend_contract_obligation_dependency_list',
|
||||
'contract_obligation_contract_dependency_list',
|
||||
'contract_entity_list'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id', 'in_time_contract_obligation_template',
|
||||
'in_time_contract_obligation_template',
|
||||
];
|
||||
|
||||
public function contract()
|
||||
@@ -38,6 +39,11 @@ class ContractObligation extends Model
|
||||
return $this->hasMany('App\Models\ContractObligationDependency', 'depend_contract_obligation_id');
|
||||
}
|
||||
|
||||
public function contract_obligation_contract_dependency()
|
||||
{
|
||||
return $this->hasMany('App\Models\ContractObligationContractDependency', 'contract_obligation_id');
|
||||
}
|
||||
|
||||
public function contract_entity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ContractEntity', 'contract_entity_id');
|
||||
@@ -67,6 +73,13 @@ class ContractObligation extends Model
|
||||
->get()->makeHidden(['contract_obligation_list', 'depend_contract_obligation_list']);
|
||||
}
|
||||
|
||||
public function getContractObligationContractDependencyListAttribute()
|
||||
{
|
||||
return $this->contract_obligation_contract_dependency()
|
||||
// ->where('status', config('constants.contract_obligation_contract_dependency.status.active'))
|
||||
->get()->makeHidden(['contract_obligation_list']);
|
||||
}
|
||||
|
||||
public function getContractEntityListAttribute()
|
||||
{
|
||||
return $this->contract_entity()->get()->makeHidden(['contract_list']);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ContractObligationContractDependencies extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContractObligationContractDependency extends Model
|
||||
{
|
||||
protected $table = 'contract_obligation_contract_dependencies';
|
||||
|
||||
protected $appends = [
|
||||
'hash_id',
|
||||
'contract_obligation_hash_id',
|
||||
'depend_contract_hash_id',
|
||||
'contract_obligation_list',
|
||||
'depend_contract_list'
|
||||
];
|
||||
|
||||
public function contract_obligation()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ContractObligation', 'contract_obligation_id');
|
||||
}
|
||||
|
||||
public function depend_contract()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Contract', 'depend_contract_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contract_obligation_contract_dependencies', $this->id);
|
||||
}
|
||||
|
||||
public function getContractObligationHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contract_obligations', $this->contract_obligation_id);
|
||||
}
|
||||
|
||||
public function getDependContractHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contracts', $this->depend_contract_id);
|
||||
}
|
||||
|
||||
public function getContractObligationListAttribute()
|
||||
{
|
||||
return $this->contract_obligation()->get()->makeHidden(['contract_obligation_dependency_list', 'depend_contract_obligation_dependency_list']);
|
||||
}
|
||||
|
||||
public function getDependContractListAttribute()
|
||||
{
|
||||
return $this->depend_contract()->get();
|
||||
}
|
||||
|
||||
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