Preparing new api for hasil-belajar
This commit is contained in:
parent
9b91fe40ce
commit
dbe517c1fc
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddUrlFieldToAccessLogsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('access_logs', function (Blueprint $table) {
|
||||||
|
$table->string('url');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('access_logs')->update(['url' => '/api/siswa']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('access_logs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('url');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
1
resources/js/components/SKHasilBelajar.js
vendored
1
resources/js/components/SKHasilBelajar.js
vendored
@ -22,6 +22,7 @@ var component = {
|
|||||||
//Siswa.cariData({
|
//Siswa.cariData({
|
||||||
//nisn: e.target.elements.nisn.value,
|
//nisn: e.target.elements.nisn.value,
|
||||||
//tanggalLahir: e.target.elements.tanggalLahir.value,
|
//tanggalLahir: e.target.elements.tanggalLahir.value,
|
||||||
|
//src: 'sk-hasil-belajar',
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
1
resources/js/components/SuratKelulusan.js
vendored
1
resources/js/components/SuratKelulusan.js
vendored
@ -28,6 +28,7 @@ var component = {
|
|||||||
Siswa.cariData({
|
Siswa.cariData({
|
||||||
nisn: e.target.elements.nisn.value,
|
nisn: e.target.elements.nisn.value,
|
||||||
tanggalLahir: e.target.elements.tanggalLahir.value,
|
tanggalLahir: e.target.elements.tanggalLahir.value,
|
||||||
|
src: 'surat-kelulusan',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
3
resources/js/models/AccessLog.js
vendored
3
resources/js/models/AccessLog.js
vendored
@ -2,10 +2,11 @@ import m from "mithril"
|
|||||||
|
|
||||||
var model = {
|
var model = {
|
||||||
current: {},
|
current: {},
|
||||||
fetch: () => {
|
fetch: src => {
|
||||||
m.request({
|
m.request({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: '/api/access_log',
|
url: '/api/access_log',
|
||||||
|
data: { src },
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
model.current = response;
|
model.current = response;
|
||||||
|
24
resources/js/models/HasilBelajar.js
vendored
Normal file
24
resources/js/models/HasilBelajar.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import m from "mihtril"
|
||||||
|
import AccessLog from "./AccessLog"
|
||||||
|
|
||||||
|
var model = {
|
||||||
|
current: {},
|
||||||
|
error: {},
|
||||||
|
cariData: data => {
|
||||||
|
model.current = {};
|
||||||
|
m.request({
|
||||||
|
method: 'post',
|
||||||
|
url: '/api/hasil-belajar',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
model.current = response;
|
||||||
|
console.log(model.current);
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
model.error = JSON.parse(e.message);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default model;
|
@ -45,14 +45,14 @@ Route::post('/siswa', function (Request $request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write to log
|
// Write to log
|
||||||
App\AccessLog::create(['siswa_id' => $siswa->id]);
|
App\AccessLog::create(['siswa_id' => $siswa->id, 'src' => $request->src]);
|
||||||
|
|
||||||
return $siswa;
|
return $siswa;
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/access_log', function () {
|
Route::get('/access_log', function (Request $request) {
|
||||||
// Get the number of unique access
|
// Get the number of unique access
|
||||||
$logs = DB::table('access_logs')->select(DB::raw('count(*) as num'))
|
$logs = DB::table('access_logs')->select(DB::raw('count(*) as num where src = ?', $request->src))
|
||||||
->groupBy('siswa_id')
|
->groupBy('siswa_id')
|
||||||
->get()
|
->get()
|
||||||
->count();
|
->count();
|
||||||
|
Loading…
Reference in New Issue
Block a user