Updated views and api

This commit is contained in:
Gregorio Chiko Putra
2019-05-10 15:41:21 +07:00
parent 019ac42b65
commit 4bb4e7c56b
15 changed files with 2831 additions and 80 deletions

View File

@@ -17,8 +17,8 @@ Route::post('/siswa', function (Request $request) {
// Validate user inputs
// Auto redirect on fail
Validator::make($request->all(), [
'nama' => 'required|string',
'nisn' => 'required|regex:/^[0-9]+$/',
'tglLahir' => 'required|regex:/^[0-9]+$/',
], [
'required' => 'Kolom :attribute harus diisi.',
'string' => 'Kolom :attribute tidak sesuai.',
@@ -26,8 +26,9 @@ Route::post('/siswa', function (Request $request) {
])->validate();
// Look for the given inputs in the resource
$siswa = App\Siswa::where('nama', $request->nama)
->where('nisn', $request->nisn)
$tglLahir = Carbon\Carbon::parse($request->tglLahir);
$siswa = App\Siswa::where('nisn', $request->nisn)
->where('tanggal_lahir', $tglLahir)
->first();
// Redirect with error if not found
@@ -43,7 +44,10 @@ Route::post('/siswa', function (Request $request) {
Route::get('/access_log', function () {
// Get the number of unique access
$logs = App\AccessLog::all()->unique()->count();
$logs = DB::table('access_logs')->select(DB::raw('count(*) as num'))
->groupBy('siswa_id')
->get()
->count();
// Get the total number of available resource
$resources = App\Siswa::count();