This commit is contained in:
afiq
2021-09-28 10:03:01 +08:00
parent 5ac8c01a71
commit fa7649d9d9
6 changed files with 335 additions and 74 deletions
+38
View File
@@ -6,6 +6,7 @@ use App\Marhun;
use App\Jemas;
use App\Cawangan;
use Illuminate\Http\Request;
use App\Audit;
use Carbon\Carbon;
@@ -62,6 +63,16 @@ class MarhunController extends Controller
'n_marhun' => $request->nilai_marhun
]);
$audit = new Audit();
$audit->users = $request->teller;
$audit->actions = 'Daftar Marhun';
$audit->norujukan = $request->norujukan;
$audit->new_data = $marhun;
$audit->kodcaw = $kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
return response()->json($marhun, 201);
}
@@ -83,8 +94,20 @@ class MarhunController extends Controller
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->delete();
$audit = new Audit();
$audit->users = $request->teller;
$audit->actions = 'Hapus Marhun';
$audit->norujukan = $norujukan;
$audit->old_data = $old_data;
$audit->kodcaw = $kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
return response('Deleted Successfully', 200);
}
@@ -92,6 +115,8 @@ class MarhunController extends Controller
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update(
[
'karat' => $request->karat,
@@ -102,6 +127,19 @@ class MarhunController extends Controller
'n_marhun' => $request->n_marhun
]);
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
$audit = new Audit();
$audit->users = $request->teller;
$audit->actions = 'Ubah Marhun';
$audit->norujukan = $norujukan;
$audit->old_data = $old_data;
$audit->new_data = $new_data;
$audit->kodcaw = $kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
return response('Edit Successfully', 200);
}