mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 12:24:01 +00:00
contract template obligation sequence update
This commit is contained in:
@@ -55,7 +55,7 @@ class ContractTemplateObligationModule extends BaseController
|
||||
|
||||
$query->where('user_id', Auth::guard('user-api')->user()->id);
|
||||
|
||||
$query->orderBy('sequence', 'desc');
|
||||
$query->orderBy('sequence', 'asc');
|
||||
|
||||
$params = [
|
||||
'contract_template_id' => $contract_template_hash_id,
|
||||
@@ -176,6 +176,32 @@ class ContractTemplateObligationModule extends BaseController
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public static function updateBatchSequence(Request $request)
|
||||
{
|
||||
$validation = ContractTemplateObligationModule::validation($request, '', 'PUT_BATCH_SEQUENCE');
|
||||
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::decodeArray('contract_template_obligations', $contract_template_obligation_id);
|
||||
|
||||
foreach ($contract_template_obligation_id as $key => $row) {
|
||||
$contract_template_obligation = ContractTemplateObligation::find($row);
|
||||
$contract_template_obligation->sequence = $key + 1;
|
||||
$contract_template_obligation->update();
|
||||
ContractTemplateObligationModule::makeLog($contract_template_obligation->id, 'user (' . Auth::guard('user-api')->user()->id . ') sequence updated');
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
$data = General::returnData($contract_template_obligation);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public static function delete(Request $request, $hash_id)
|
||||
{
|
||||
$id = Hasher::decode('contract_template_obligations', $hash_id);
|
||||
@@ -236,6 +262,12 @@ class ContractTemplateObligationModule extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
if ($method == 'PUT_BATCH_SEQUENCE') {
|
||||
$rule = [
|
||||
'contract_template_obligation_id' => ['required', new UnderCheck('contract_template_obligation'), new ExistCheck('contract_template_obligation')],
|
||||
];
|
||||
}
|
||||
|
||||
if ($method == 'DEL') {
|
||||
$data['id'] = $id;
|
||||
$rule = [
|
||||
|
||||
Reference in New Issue
Block a user