mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
contract generate
This commit is contained in:
+35
-2
@@ -2,10 +2,43 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'contracts';
|
||||
|
||||
protected $appends = ['hash_id', 'contract_obligation_list'];
|
||||
|
||||
protected $hidden = [
|
||||
'id', 'in_time_contract_template',
|
||||
];
|
||||
|
||||
public function contract_obligation()
|
||||
{
|
||||
return $this->hasMany('App\Models\ContractObligation', 'contract_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contracts', $this->id);
|
||||
}
|
||||
|
||||
public function getContractObligationListAttribute()
|
||||
{
|
||||
return $this->contract_obligation()->get()->makeHidden(['contract_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') : '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,72 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContractObligation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'contract_obligations';
|
||||
|
||||
protected $appends = [
|
||||
'hash_id',
|
||||
'contract_list',
|
||||
'contract_obligation_dependency_list',
|
||||
'depend_contract_obligation_dependency_list'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id', 'in_time_contract_obligation_template',
|
||||
];
|
||||
|
||||
public function contract()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Contract', 'contract_id');
|
||||
}
|
||||
|
||||
public function contract_obligation_dependency()
|
||||
{
|
||||
return $this->hasMany('App\Models\ContractObligationDependency', 'contract_obligation_id');
|
||||
}
|
||||
|
||||
public function depend_contract_obligation_dependency()
|
||||
{
|
||||
return $this->hasMany('App\Models\ContractObligationDependency', 'depend_contract_obligation_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contract_obligations', $this->id);
|
||||
}
|
||||
|
||||
public function getContractListAttribute()
|
||||
{
|
||||
return $this->contract()->get()->makeHidden(['contract_obligation_list']);
|
||||
}
|
||||
|
||||
public function getContractObligationDependencyListAttribute()
|
||||
{
|
||||
return $this->contract_obligation_dependency()
|
||||
->where('status', config('constants.contract_obligation.status.active'))
|
||||
->get()->makeHidden(['contract_obligation_list', 'depend_contract_obligation_list']);
|
||||
}
|
||||
|
||||
public function getDependContractObligationDependencyListAttribute()
|
||||
{
|
||||
return $this->depend_contract_obligation_dependency()
|
||||
->where('status', config('constants.contract_obligation.status.active'))
|
||||
->get()->makeHidden(['contract_obligation_list', 'depend_contract_obligation_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') : '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,11 @@ class ContractTemplate extends Model
|
||||
|
||||
public function getContractTemplateObligationListAttribute()
|
||||
{
|
||||
return $this->contract_template_obligation()->get()->makeHidden(['contract_template_list']);
|
||||
return $this->contract_template_obligation()
|
||||
->orderBy('sequence', 'asc')
|
||||
->where('status', config('constants.contract_template_obligation.status.active'))
|
||||
->get()
|
||||
->makeHidden(['contract_template_list']);
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
|
||||
@@ -69,7 +69,7 @@ class ContractTemplateObligation extends Model
|
||||
|
||||
public function getContractTemplateObligationDependencyStructure($contract_template_obligation_id = [], $contract_template_obligation_id_structure = [])
|
||||
{
|
||||
$contract_template_obligation_id = Hasher::decode('contract_template_obligations', $contract_template_obligation_id[0]);
|
||||
$contract_template_obligation_id = !empty($contract_template_obligation_id) ? Hasher::decode('contract_template_obligations', $contract_template_obligation_id[0]) : $this->id;
|
||||
$contract_template_obligation = ContractTemplateObligation::find($contract_template_obligation_id);
|
||||
|
||||
if (!empty($contract_template_obligation->contract_template_obligation_dependency_list)) {
|
||||
|
||||
Reference in New Issue
Block a user