mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
contract template obligation dependency api
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\User\Api;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\Http\Modules\User\ContractTemplateObligationDependencyModule;
|
||||||
|
|
||||||
|
use App\Http\Controllers\User\BaseController;
|
||||||
|
|
||||||
|
class ContractTemplateObligationDependencyController extends BaseController
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list(Request $request)
|
||||||
|
{
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependencyModule::list($request);
|
||||||
|
return $contract_template_obligation_dependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $hash_id)
|
||||||
|
{
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependencyModule::show($request, $hash_id);
|
||||||
|
return $contract_template_obligation_dependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependencyModule::store($request);
|
||||||
|
return $contract_template_obligation_dependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $hash_id)
|
||||||
|
{
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependencyModule::update($request, $hash_id);
|
||||||
|
return $contract_template_obligation_dependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request, $hash_id)
|
||||||
|
{
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependencyModule::delete($request, $hash_id);
|
||||||
|
return $contract_template_obligation_dependency;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Modules\User;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use App\Models\ContractTemplateObligationDependency;
|
||||||
|
use App\Models\ContractTemplateObligation;
|
||||||
|
|
||||||
|
use App\Http\Modules\User\ContractTemplateObligationModule;
|
||||||
|
|
||||||
|
use App\Http\Rules\User\UnderCheck;
|
||||||
|
use App\Http\Rules\User\ExistCheck;
|
||||||
|
use App\Http\Rules\User\ContractTemplateObligationDependencyCheck;
|
||||||
|
|
||||||
|
use App\Http\Helpers\General;
|
||||||
|
use App\Http\Helpers\Hasher;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
use App\Http\Controllers\User\BaseController;
|
||||||
|
|
||||||
|
class ContractTemplateObligationDependencyModule extends BaseController
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function list(Request $request)
|
||||||
|
{
|
||||||
|
General::storeCachePerviousQuery($request->query(), 'contract_template_obligation_dependency_query');
|
||||||
|
|
||||||
|
$name = $request->get('name', null);
|
||||||
|
$status = $request->get('status', []);
|
||||||
|
$page = $request->get('page', null);
|
||||||
|
$limit = $request->get('limit', 10);
|
||||||
|
|
||||||
|
$query = ContractTemplateObligationDependency::query();
|
||||||
|
|
||||||
|
if (strlen($name) > 0) {
|
||||||
|
$query->where('name', 'like', '%' . $name . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($status) > 0) {
|
||||||
|
$query->whereIn('status', $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->where('user_id', Auth::guard('user-api')->user()->id);
|
||||||
|
|
||||||
|
$query->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'name' => $name,
|
||||||
|
'status' => $status,
|
||||||
|
'page' => $page
|
||||||
|
];
|
||||||
|
|
||||||
|
$contract_template_obligation_dependency_list = $query->paginate($limit);
|
||||||
|
|
||||||
|
$extract = [];
|
||||||
|
foreach ($contract_template_obligation_dependency_list as $key => $row) {
|
||||||
|
$extract[] = $row;
|
||||||
|
|
||||||
|
}
|
||||||
|
$pagination = General::paginationGenerator($contract_template_obligation_dependency_list, $params, $extract);
|
||||||
|
|
||||||
|
return $pagination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function show(Request $request, $hash_id)
|
||||||
|
{
|
||||||
|
$id = Hasher::decode('contract_template_obligation_dependencies', $hash_id);
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependency::find($id);
|
||||||
|
if ($contract_template_obligation_dependency) {
|
||||||
|
$data = General::returnData($contract_template_obligation_dependency, '');
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
$data = General::returnNotFoundData();
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function store(Request $request)
|
||||||
|
{
|
||||||
|
$validation = ContractTemplateObligationDependencyModule::validation($request);
|
||||||
|
if (!$validation->status) {
|
||||||
|
return response()->json($validation, 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$contract_template_obligation_id = $request->input('contract_template_obligation_id');
|
||||||
|
$contract_template_obligation_id = Hasher::decode('contract_template_obligations', $contract_template_obligation_id[0]);
|
||||||
|
$contarct_template_obligation = ContractTemplateObligation::find($contract_template_obligation_id);
|
||||||
|
|
||||||
|
$depend_contract_template_obligation_id = $request->input('depend_contract_template_obligation_id');
|
||||||
|
$depend_contract_template_obligation_id = Hasher::decode('contract_template_obligations', $depend_contract_template_obligation_id[0]);
|
||||||
|
$depend_contract_template_obligation = ContractTemplateObligation::find($depend_contract_template_obligation_id);
|
||||||
|
|
||||||
|
$contract_template_obligation_dependency = new ContractTemplateObligationDependency();
|
||||||
|
$contract_template_obligation_dependency->user_id = Auth::guard('user-api')->user()->id;
|
||||||
|
$contract_template_obligation_dependency->contract_template_obligation_id = $contarct_template_obligation->id;
|
||||||
|
$contract_template_obligation_dependency->depend_contract_template_obligation_id = $depend_contract_template_obligation->id;
|
||||||
|
$contract_template_obligation_dependency->status = config('constants.contract_template_obligation_dependency.status.active');
|
||||||
|
$contract_template_obligation_dependency->save();
|
||||||
|
|
||||||
|
// log
|
||||||
|
ContractTemplateObligationModule::makeLog($contract_template_obligation_dependency->contract_template_obligation_id, 'user (' . Auth::guard('user-api')->user()->id . ') created dependency');
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
$query_string = General::getCachePerviousQuery('contract_template_obligation_dependency_query');
|
||||||
|
$data = General::returnData($contract_template_obligation_dependency, $query_string);
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function delete(Request $request, $hash_id)
|
||||||
|
{
|
||||||
|
$id = Hasher::decode('contract_template_obligation_dependencies', $hash_id);
|
||||||
|
$validation = ContractTemplateObligationDependencyModule::validation($request, $hash_id, 'DEL');
|
||||||
|
if (!$validation->status) {
|
||||||
|
return response()->json($validation, 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$contract_template_obligation_dependency = ContractTemplateObligationDependency::find($id);
|
||||||
|
$contract_template_obligation_dependency->status = config('constants.contract_template_obligation_dependency.status.delete');
|
||||||
|
$contract_template_obligation_dependency->update();
|
||||||
|
|
||||||
|
// log
|
||||||
|
ContractTemplateObligationModule::makeLog($contract_template_obligation_dependency->contract_template_obligation_id, 'user (' . Auth::guard('user-api')->user()->id . ') delete dependency');
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
$query_string = General::getCachePerviousQuery('contract_template_obligation_dependency_query');
|
||||||
|
$data = General::returnData($contract_template_obligation_dependency, $query_string);
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function validation(Request $request, $id = '', $method = 'POST')
|
||||||
|
{
|
||||||
|
$data = $request->all();
|
||||||
|
$rule= [];
|
||||||
|
|
||||||
|
if ($method == 'POST') {
|
||||||
|
$rule = [
|
||||||
|
'contract_template_obligation_id' => [
|
||||||
|
'required',
|
||||||
|
new UnderCheck('contract_template_obligation'),
|
||||||
|
new ExistCheck('contract_template_obligation'),
|
||||||
|
new ContractTemplateObligationDependencyCheck($data['depend_contract_template_obligation_id'] ?? [])
|
||||||
|
],
|
||||||
|
'depend_contract_template_obligation_id' => [
|
||||||
|
'required',
|
||||||
|
new UnderCheck('contract_template_obligation'),
|
||||||
|
new ExistCheck('contract_template_obligation')
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method == 'DEL') {
|
||||||
|
$data['id'] = $id;
|
||||||
|
$rule = [
|
||||||
|
'id' => [new UnderCheck('contract_template_obligation_dependency'), new ExistCheck('contract_template_obligation_dependency')],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = Validator::make($data, $rule, config('error_code'));
|
||||||
|
|
||||||
|
$errors = $validator->errors();
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
$data = General::returnErrorData($errors);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (object)['status' => true];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Rules\User;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use App\Models\ContractTemplateObligation;
|
||||||
|
|
||||||
|
use App\Http\Helpers\Hasher;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
|
class ContractTemplateObligationDependencyCheck implements Rule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new rule instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
private $depend_template_contract_obligation_id;
|
||||||
|
|
||||||
|
public function __construct($depend_template_contract_obligation_id = '')
|
||||||
|
{
|
||||||
|
$this->depend_template_contract_obligation_id = $depend_template_contract_obligation_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the validation rule passes.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function passes($attribute, $value)
|
||||||
|
{
|
||||||
|
$this->attribute = $attribute;
|
||||||
|
$value = is_array($value) ? $value : [$value];
|
||||||
|
|
||||||
|
if ($value[0] != $this->depend_template_contract_obligation_id[0]) {
|
||||||
|
$contract_template_obligation_id = Hasher::decode('contract_template_obligations', $value[0]);
|
||||||
|
$contract_template_obligation = ContractTemplateObligation::find($contract_template_obligation_id);
|
||||||
|
$depend_contract_template_obligation_id = Hasher::decode('contract_template_obligations', $this->depend_template_contract_obligation_id[0]);
|
||||||
|
$depend_contract_template_obligation = ContractTemplateObligation::find($depend_contract_template_obligation_id);
|
||||||
|
|
||||||
|
$contract_template_obligation_dependency_structure = $contract_template_obligation->getContractTemplateObligationDependencyStructure([$contract_template_obligation->hash_id]);
|
||||||
|
|
||||||
|
if (in_array($depend_contract_template_obligation->hash_id, $contract_template_obligation_dependency_structure)) {
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation error message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return config('error_code.obligation_depend_error');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,13 +11,28 @@ class ContractTemplateObligation extends Model
|
|||||||
{
|
{
|
||||||
protected $table = 'contract_template_obligations';
|
protected $table = 'contract_template_obligations';
|
||||||
|
|
||||||
protected $appends = ['hash_id', 'contract_template_list'];
|
protected $appends = [
|
||||||
|
'hash_id',
|
||||||
|
'contract_template_list',
|
||||||
|
'contract_template_obligation_dependency_list',
|
||||||
|
'depend_contract_template_obligation_dependency_list'
|
||||||
|
];
|
||||||
|
|
||||||
public function contract_template()
|
public function contract_template()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\ContractTemplate', 'contract_template_id');
|
return $this->belongsTo('App\Models\ContractTemplate', 'contract_template_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function contract_template_obligation_dependency()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\ContractTemplateObligationDependency', 'contract_template_obligation_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function depend_contract_template_obligation_dependency()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\ContractTemplateObligationDependency', 'depend_contract_template_obligation_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function getHashIdAttribute()
|
public function getHashIdAttribute()
|
||||||
{
|
{
|
||||||
return Hasher::encode('contract_template_obligations', $this->id);
|
return Hasher::encode('contract_template_obligations', $this->id);
|
||||||
@@ -28,6 +43,20 @@ class ContractTemplateObligation extends Model
|
|||||||
return $this->contract_template()->get()->makeHidden(['contract_template_obligation_list']);
|
return $this->contract_template()->get()->makeHidden(['contract_template_obligation_list']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getContractTemplateObligationDependencyListAttribute()
|
||||||
|
{
|
||||||
|
return $this->contract_template_obligation_dependency()
|
||||||
|
->where('status', config('constants.contract_template_obligation.status.active'))
|
||||||
|
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependContractTemplateObligationDependencyListAttribute()
|
||||||
|
{
|
||||||
|
return $this->depend_contract_template_obligation_dependency()
|
||||||
|
->where('status', config('constants.contract_template_obligation.status.active'))
|
||||||
|
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
|
||||||
|
}
|
||||||
|
|
||||||
public function getUpdatedAtAttribute($date)
|
public function getUpdatedAtAttribute($date)
|
||||||
{
|
{
|
||||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||||
@@ -37,4 +66,21 @@ class ContractTemplateObligation extends Model
|
|||||||
{
|
{
|
||||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = ContractTemplateObligation::find($contract_template_obligation_id);
|
||||||
|
|
||||||
|
if (!empty($contract_template_obligation->contract_template_obligation_dependency_list)) {
|
||||||
|
foreach ($contract_template_obligation->contract_template_obligation_dependency_list as $key => $row) {
|
||||||
|
$contract_template_obligation_id_structure[] = $row->depend_contract_template_obligation_hash_id;
|
||||||
|
if (!empty($row->depend_contract_template_obligation_list)) {
|
||||||
|
return $this->getContractTemplateObligationDependencyStructure([$row->depend_contract_template_obligation_hash_id], $contract_template_obligation_id_structure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $contract_template_obligation_id_structure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ContractTemplateObligationDependencies 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 ContractTemplateObligationDependency extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'contract_template_obligation_dependencies';
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'hash_id',
|
||||||
|
'contract_template_obligation_hash_id',
|
||||||
|
'depend_contract_template_obligation_hash_id',
|
||||||
|
'contract_template_obligation_list',
|
||||||
|
'depend_contract_template_obligation_list'
|
||||||
|
];
|
||||||
|
|
||||||
|
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 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') : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,13 @@
|
|||||||
'pending' => 9
|
'pending' => 9
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'contract_template_obligation_dependency' => [
|
||||||
|
'status' => [
|
||||||
|
'active' => 1,
|
||||||
|
'delete' => 2,
|
||||||
|
'pending' => 9
|
||||||
|
]
|
||||||
|
],
|
||||||
'contract_obligation' => [
|
'contract_obligation' => [
|
||||||
'complete_status' => [
|
'complete_status' => [
|
||||||
'pending' => 9,
|
'pending' => 9,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
'email' => 'EMAIL_ERROR',
|
'email' => 'EMAIL_ERROR',
|
||||||
'unique' => 'UNIQUE_ERRO',
|
'unique' => 'UNIQUE_ERRO',
|
||||||
'confirmed' => 'CONFIRM_ERROR',
|
'confirmed' => 'CONFIRM_ERROR',
|
||||||
|
'obligation_depend_error' => 'OBLIGATION_DEPEND_ERROR',
|
||||||
'min' => [
|
'min' => [
|
||||||
'string' => 'MIN_ERROR_:min',
|
'string' => 'MIN_ERROR_:min',
|
||||||
],
|
],
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ class CreateContractTemplateObligationDependenciesTable extends Migration
|
|||||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
$table->bigInteger('contract_template_obligation_id')->unsigned()->nullable();
|
$table->bigInteger('contract_template_obligation_id')->unsigned()->nullable();
|
||||||
$table->foreign('contract_template_obligation_id', 'ctod_cto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
|
$table->foreign('contract_template_obligation_id', 'ctod_cto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
|
||||||
$table->bigInteger('depend_template_contract_obligation_id')->unsigned()->nullable();
|
$table->bigInteger('depend_contract_template_obligation_id')->unsigned()->nullable();
|
||||||
$table->foreign('depend_template_contract_obligation_id', 'dctod_cto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
|
$table->foreign('depend_contract_template_obligation_id', 'ctod_dcto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
|
||||||
$table->integer('status')->nullable()->default(1);
|
$table->integer('status')->nullable()->default(1);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ class SodaVendorContractTemplateObligationDependenciesTableSeeder extends Seeder
|
|||||||
'id' => 1,
|
'id' => 1,
|
||||||
'user_id' => 2,
|
'user_id' => 2,
|
||||||
'contract_template_obligation_id' => 2, // vendor machine drop selected soda to user
|
'contract_template_obligation_id' => 2, // vendor machine drop selected soda to user
|
||||||
'depend_template_contract_obligation_id' => 1, // user insert coin and select soda at vendor machine
|
'depend_contract_template_obligation_id' => 1, // user insert coin and select soda at vendor machine
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'updated_at' => date('Y-m-d H:i:s')
|
'updated_at' => date('Y-m-d H:i:s')
|
||||||
@@ -29,7 +29,7 @@ class SodaVendorContractTemplateObligationDependenciesTableSeeder extends Seeder
|
|||||||
'id' => 2,
|
'id' => 2,
|
||||||
'user_id' => 2,
|
'user_id' => 2,
|
||||||
'contract_template_obligation_id' => 3, // user pickup the soda
|
'contract_template_obligation_id' => 3, // user pickup the soda
|
||||||
'depend_template_contract_obligation_id' => 2, // vendor machine drop selected soda to user
|
'depend_contract_template_obligation_id' => 2, // vendor machine drop selected soda to user
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'updated_at' => date('Y-m-d H:i:s')
|
'updated_at' => date('Y-m-d H:i:s')
|
||||||
|
|||||||
@@ -91,6 +91,45 @@ Route::group(['namespace' => 'User', 'prefix' => 'user-backsys/api'], function (
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Contract Templete Obligation
|
||||||
|
Route::prefix('contract-template-obligation-dependency')->group(function () {
|
||||||
|
Route::get('list',
|
||||||
|
[
|
||||||
|
'as' => 'api.contract-template-obligation-dependency.list',
|
||||||
|
'uses' => 'ContractTemplateObligationDependencyController@list',
|
||||||
|
'middleware' => ['permission:view contract_template_obligation_dependency']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Route::get('show/{hash_id}',
|
||||||
|
[
|
||||||
|
'as' => 'api.contract-template-obligation-dependency.show',
|
||||||
|
'uses' => 'ContractTemplateObligationDependencyController@show',
|
||||||
|
'middleware' => ['permission:view contract_template_obligation_dependency']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Route::post('store',
|
||||||
|
[
|
||||||
|
'as' => 'api.contract-template-obligation-dependency.store',
|
||||||
|
'uses' => 'ContractTemplateObligationDependencyController@store',
|
||||||
|
'middleware' => ['permission:add contract_template_obligation_dependency']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Route::put('update/{hash_id}',
|
||||||
|
[
|
||||||
|
'as' => 'api.contract-template-obligation-dependency.update',
|
||||||
|
'uses' => 'ContractTemplateObligationDependencyController@update',
|
||||||
|
'middleware' => ['permission:edit contract_template_obligation_dependency']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Route::delete('delete/{hash_id}',
|
||||||
|
[
|
||||||
|
'as' => 'api.contract-template-obligation-dependency.delete',
|
||||||
|
'uses' => 'ContractTemplateObligationDependencyController@delete',
|
||||||
|
'middleware' => ['permission:delete contract_template_obligation_dependency']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user