fix va bayar

parent f79abb5b
...@@ -18,14 +18,18 @@ ...@@ -18,14 +18,18 @@
class RegistrasiController extends Controller class RegistrasiController extends Controller
{ {
public function create(){ public function create(){
// $jumlahPendaftar = Registrasi::count();
// $nourut = sprintf("%05s", $jumlahPendaftar+1);
// $koderegistrasi = 'REG-'.$komponen[0].$komponen[1].$komponen[2].$nourut;
$kegiatan = Kegiatan::get(); $kegiatan = Kegiatan::get();
$konferensi = Konferensi::get(); $konferensi = Konferensi::get();
$jumlahPendaftar = Registrasi::count(); $date = Date('Y-m-d');
$nourut = sprintf("%05s", $jumlahPendaftar+1); $lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi');
$nourut = sprintf("%05s", substr($lastKode, -5)+1);
$tgldaftar = Carbon::now()->format('d-m-Y'); $tgldaftar = Carbon::now()->format('d-m-Y');
$komponen = explode('-', $tgldaftar); $komponen = explode('-', $tgldaftar);
// $koderegistrasi = 'REG-'.$komponen[0].$komponen[1].$komponen[2].$nourut; $koderegistrasi = '-';
$koderegistrasi = $komponen[0].$komponen[1].$nourut;
$data = [ $data = [
'kegiatan' => $kegiatan, 'kegiatan' => $kegiatan,
...@@ -54,6 +58,13 @@ public function store(Request $request) { ...@@ -54,6 +58,13 @@ public function store(Request $request) {
DB::beginTransaction(); DB::beginTransaction();
try{ try{
$date = Date('Y-m-d');
$lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi');
$nourut = sprintf("%05s", substr($lastKode, -5)+1);
$tgldaftar = Carbon::now()->format('d-m-Y');
$komponen = explode('-', $tgldaftar);
$kode_registrasi = $komponen[0].$komponen[1].$nourut;
$registrasi = [ $registrasi = [
'nama' => strip_tags($request->nama), 'nama' => strip_tags($request->nama),
'email' => strip_tags($request->email), 'email' => strip_tags($request->email),
...@@ -63,7 +74,7 @@ public function store(Request $request) { ...@@ -63,7 +74,7 @@ public function store(Request $request) {
'alamat' => strip_tags($request->alamat), 'alamat' => strip_tags($request->alamat),
'kode_pos' => strip_tags($request->kodepos), 'kode_pos' => strip_tags($request->kodepos),
'kota' => strip_tags($request->kota), 'kota' => strip_tags($request->kota),
'kode_registrasi' => strip_tags($request->kode_registrasi) 'kode_registrasi' => strip_tags($kode_registrasi)
]; ];
$tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s'); $tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s');
...@@ -72,7 +83,6 @@ public function store(Request $request) { ...@@ -72,7 +83,6 @@ public function store(Request $request) {
$konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first(); $konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first();
$registrasi = Registrasi::query()->create($registrasi); $registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id; $id_registrasi = $registrasi->id;
$kode_registrasi = $registrasi->kode_registrasi;
//inisial harga //inisial harga
// dd($konaspi); // dd($konaspi);
$totalHarga = (int) $konaspi->harga; $totalHarga = (int) $konaspi->harga;
...@@ -110,6 +120,8 @@ public function store(Request $request) { ...@@ -110,6 +120,8 @@ public function store(Request $request) {
$arrResponse = json_decode($generatedVa, true); $arrResponse = json_decode($generatedVa, true);
$registrasi->status_va = $arrResponse['BTNresponse']; $registrasi->status_va = $arrResponse['BTNresponse'];
$registrasi->tagihan = $totalHarga;
$registrasi->save(); $registrasi->save();
if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){ if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
| |
*/ */
'timezone' => 'UTC', 'timezone' => 'Asia/Jakarta',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
| |
*/ */
'locale' => 'en', 'locale' => 'id',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment