function logsession

This commit is contained in:
Ainie Hayatie
2024-01-30 12:32:43 +08:00
parent 0322112863
commit 51b1f32c07
4 changed files with 126 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?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);
}
}