|
|
|
@ -24,14 +24,14 @@ class ProductTransactionController extends Controller
|
|
|
|
|
if ($result) { |
|
|
|
|
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Add data Transaction failed!', 'code' => 400], 400); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Add Transaction failed!', 'code' => 400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function edit($id) |
|
|
|
|
{ |
|
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400); |
|
|
|
|
die(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -40,50 +40,30 @@ class ProductTransactionController extends Controller
|
|
|
|
|
if ($result) { |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'failed get data Transaction, please try again later!', 'code' => 400], 400); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed get data transaction, please try again later!', 'code' => 400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id) |
|
|
|
|
{ |
|
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data = ProductTransaction::find($id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($data) { |
|
|
|
|
if($data){ |
|
|
|
|
$result = $data->update($request->all()); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data Transaction not found!', 'code' => 400], 400); |
|
|
|
|
}else{ |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data transaction not found!','code'=>400], 400); |
|
|
|
|
die(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'data Transaction successfully updated!', 'code' => 200], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data Transaction failed updated!', 'code' => 400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function delete($id) |
|
|
|
|
{ |
|
|
|
|
$data = ProductTransaction::find($id); |
|
|
|
|
|
|
|
|
|
if ($data) { |
|
|
|
|
$delete = $data->delete(); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data Transaction not found!', 'code' => 400], 400); |
|
|
|
|
die(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($delete) { |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'data Transaction successfully deleted!', 'code' => 200], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data Transaction failed deleted!', 'code' => 400], 400); |
|
|
|
|
if($result){ |
|
|
|
|
return response()->json(['status'=>'success','message'=>'Data transaction successfully updated!','code'=>200], 200); |
|
|
|
|
}else{ |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data transaction failed updated!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|