60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\LogSession;
|
|
use App\Cawangan;
|
|
use App\Logsession as AppLogsession;
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
class LogController extends Controller
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public function logSession($kodcaw, Request $request)
|
|
{
|
|
// dd($request->all());
|
|
|
|
$logsession = Logsession::on('mysql7')->where('kodcaw', '=', $kodcaw)
|
|
->create([
|
|
'nama' => $request->nama,
|
|
'nokp' => $request->nokp,
|
|
'kodcaw' => $request->kodcaw,
|
|
'email' => $request->email,
|
|
'taraf' => $request->taraf,
|
|
|
|
]);
|
|
|
|
|
|
return response()->json($logsession);
|
|
}
|
|
|
|
public function checkNokpSession($kodcaw, $nokp, $tarikh)
|
|
{
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
|
|
|
$checknokp = Logsession::on('mysql7')->where('kodcaw', '=', $kodcaw)
|
|
->where('nokp', '=', $nokp)
|
|
->where('created_at','LIKE',"%{$tarikh}%")
|
|
->get();
|
|
|
|
if (sizeof($checknokp) != 0) {
|
|
$newnokp = $nokp;
|
|
} else {
|
|
|
|
$newnokp = 'NULL';
|
|
}
|
|
return response()->json($newnokp);
|
|
}
|
|
|
|
|
|
}
|