Updated request variable, updated api test

This commit is contained in:
Gregorio Chiko Putra
2019-05-10 16:25:17 +07:00
parent 4bb4e7c56b
commit 07eb2af135
3 changed files with 15 additions and 15 deletions

View File

@@ -18,17 +18,16 @@ Route::post('/siswa', function (Request $request) {
// Auto redirect on fail
Validator::make($request->all(), [
'nisn' => 'required|regex:/^[0-9]+$/',
'tglLahir' => 'required|regex:/^[0-9]+$/',
'tanggalLahir' => 'required|regex:/^[0-9]+$/',
], [
'required' => 'Kolom :attribute harus diisi.',
'string' => 'Kolom :attribute tidak sesuai.',
'regex' => 'Kolom :attribute tidak sesuai.',
])->validate();
// Look for the given inputs in the resource
$tglLahir = Carbon\Carbon::parse($request->tglLahir);
$tanggalLahir = Carbon\Carbon::parse($request->tanggalLahir)->format('Y-m-d');
$siswa = App\Siswa::where('nisn', $request->nisn)
->where('tanggal_lahir', $tglLahir)
->where('tanggal_lahir', $tanggalLahir)
->first();
// Redirect with error if not found