Commit 40063f71 by Triyah Fatmawati

Add NIK dan ubah kode registrasi jadi 5 digit

parent 78c1c32f
......@@ -12,6 +12,7 @@
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\MultipartStream;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
......@@ -62,11 +63,16 @@ public function preview(Request $request){
try{
$date = Date('Y-m-d');
$lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi');
$nourut = sprintf("%05s", ((int) substr($lastKode, -5))+1);
$tgldaftar = Carbon::now()->format('d-m-Y');
$komponen = explode('-', $tgldaftar);
$kode_registrasi = $komponen[0].$komponen[1].$nourut;
// $lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi');
// $nourut = sprintf("%05s", ((int) substr($lastKode, -5))+1);
// $tgldaftar = Carbon::now()->format('d-m-Y');
// $komponen = explode('-', $tgldaftar);
// $kode_registrasi = $komponen[0].$komponen[1].$nourut;
$urutanTerakhir = Registrasi::query()->max('urutan');
$urutan = (int) $urutanTerakhir + 1;
$nourut = sprintf("%05s", $urutan);
$kode_registrasi = $nourut;
$registrasi = [
'nama' => strip_tags($request->nama),
......@@ -77,7 +83,9 @@ public function preview(Request $request){
'alamat' => strip_tags($request->alamat),
'kode_pos' => strip_tags($request->kodepos),
'kota' => strip_tags($request->kota),
'kode_registrasi' => strip_tags($kode_registrasi)
'kode_registrasi' => strip_tags($kode_registrasi),
'urutan' => $urutan,
'nik' => strip_tags($request->nik)
];
$tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s');
......
......@@ -31,7 +31,9 @@ class Registrasi extends Model
'kode_registrasi',
'tagihan',
'status_va',
'tanggal_bayar'
'tanggal_bayar',
'urutan',
'nik'
];
public function pkKegiatan(){
......
......@@ -16,13 +16,20 @@
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12 form-group" @if ($errors->has('nama')) has-error @endif>
<div class="col-6 form-group" @if ($errors->has('nama')) has-error @endif>
<label>Nama</label>
<input type="text" id="nama" name="nama" class="form-control" required="" placeholder="" value="{{ old('nama')}}">
@if ($errors->has('nama'))
<label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label>
@endif
</div>
<div class="col-6 form-group" @if ($errors->has('nik')) has-error @endif>
<label>NIK</label>
<input type="text" id="nik" name="nik" class="form-control" required="" placeholder="" value="{{ old('nik')}}">
@if ($errors->has('nik'))
<label id="login-error" class="error" for="nik" style="color: red">{{$errors->first('nik')}}</label>
@endif
</div>
</div>
<div class="row">
<div class="col-6 form-group" @if ($errors->has('email')) has-error @endif>
......
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