|
|
|
@ -45,29 +45,6 @@ class Tv extends Model {
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// -- RELATED TO REQUEST
|
|
|
|
// -- RELATED TO REQUEST
|
|
|
|
public static function modifyAndValidateUpsertRequest(Request $request, $isUpdate = false) {
|
|
|
|
|
|
|
|
if($request->code) $request->merge(['code' => strtoupper($request->code)]);
|
|
|
|
|
|
|
|
$validationRules = [
|
|
|
|
|
|
|
|
'code' => ['required','string',Rule::unique('tvs', 'code')
|
|
|
|
|
|
|
|
->when($request->id, function($q, $id) {
|
|
|
|
|
|
|
|
$q->whereNot('id', $id);
|
|
|
|
|
|
|
|
})],
|
|
|
|
|
|
|
|
'col1' => 'nullable|string',
|
|
|
|
|
|
|
|
'col2' => 'nullable|string',
|
|
|
|
|
|
|
|
'col3' => 'nullable|string',
|
|
|
|
|
|
|
|
'col4' => 'nullable|string',
|
|
|
|
|
|
|
|
'col5' => 'nullable|string',
|
|
|
|
|
|
|
|
'col6' => 'nullable|string',
|
|
|
|
|
|
|
|
'col7' => 'nullable|string',
|
|
|
|
|
|
|
|
'col8' => 'nullable|string',
|
|
|
|
|
|
|
|
'col9' => 'nullable|string',
|
|
|
|
|
|
|
|
'col10' => 'nullable|string',
|
|
|
|
|
|
|
|
'notes' => 'nullable|string',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
if($isUpdate) $validationRules['id'] = 'nullable|integer|exists:App\Models\Tv';
|
|
|
|
|
|
|
|
$request->validate();
|
|
|
|
|
|
|
|
return $request;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function updateFromRequest(Request $request) {
|
|
|
|
public static function updateFromRequest(Request $request) {
|
|
|
|
if($request->code) $request->merge(['code' => strtoupper($request->code)]);
|
|
|
|
if($request->code) $request->merge(['code' => strtoupper($request->code)]);
|
|
|
|
$request->validate([
|
|
|
|
$request->validate([
|
|
|
|
@ -106,10 +83,13 @@ class Tv extends Model {
|
|
|
|
$tv->notes = $request->notes;
|
|
|
|
$tv->notes = $request->notes;
|
|
|
|
$tv->update();
|
|
|
|
$tv->update();
|
|
|
|
|
|
|
|
|
|
|
|
// try to sys_to_sys with indokargo
|
|
|
|
return JSONResponse::Success(['message'=>'Success to update tv data']);
|
|
|
|
$jsonResponse = Indokargo::updateTVAddress($request, $tv->id, $tv->ik_address_id);
|
|
|
|
|
|
|
|
DB::commit();
|
|
|
|
// TODO: waiting from ops workflow
|
|
|
|
return $jsonResponse;
|
|
|
|
// // try to sys_to_sys with indokargo
|
|
|
|
|
|
|
|
// $jsonResponse = Indokargo::updateTVAddress($request, $tv->id, $tv->ik_address_id);
|
|
|
|
|
|
|
|
// DB::commit();
|
|
|
|
|
|
|
|
// return $jsonResponse;
|
|
|
|
} catch(\Throwable $th) {
|
|
|
|
} catch(\Throwable $th) {
|
|
|
|
DB::rollback();
|
|
|
|
DB::rollback();
|
|
|
|
throw $th;
|
|
|
|
throw $th;
|
|
|
|
@ -123,12 +103,14 @@ class Tv extends Model {
|
|
|
|
$tv = Tv::findOrFail($request->id);
|
|
|
|
$tv = Tv::findOrFail($request->id);
|
|
|
|
$tv->is_active = !$tv->is_active;
|
|
|
|
$tv->is_active = !$tv->is_active;
|
|
|
|
$tv->save();
|
|
|
|
$tv->save();
|
|
|
|
|
|
|
|
return JSONResponse::Success(['message'=>'Success to change tv status']);
|
|
|
|
|
|
|
|
|
|
|
|
// try to sys_to_sys with indokargo
|
|
|
|
// TODO: waiting from ops workflow
|
|
|
|
$jsonResponse = Indokargo::changeStatusAddress(new Request(['is_active' => $tv->is_active]),
|
|
|
|
// // try to sys_to_sys with indokargo
|
|
|
|
$tv->id, $tv->ik_address_id);
|
|
|
|
// $jsonResponse = Indokargo::changeStatusAddress(new Request(['is_active' => $tv->is_active]),
|
|
|
|
DB::commit();
|
|
|
|
// $tv->id, $tv->ik_address_id);
|
|
|
|
return $jsonResponse;
|
|
|
|
// DB::commit();
|
|
|
|
|
|
|
|
// return $jsonResponse;
|
|
|
|
} catch(\Throwable $th) {
|
|
|
|
} catch(\Throwable $th) {
|
|
|
|
DB::rollback();
|
|
|
|
DB::rollback();
|
|
|
|
throw $th;
|
|
|
|
throw $th;
|
|
|
|
|