-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathdebug_semester.php
More file actions
41 lines (32 loc) · 1.31 KB
/
debug_semester.php
File metadata and controls
41 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once 'vendor/autoload.php';
$app = require_once 'bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
use App\Models\Mahasiswa;
use App\Models\TahunAkademik;
$output = "";
// Get first mahasiswa
$mahasiswa = Mahasiswa::first();
$output .= "Mahasiswa: " . ($mahasiswa->user->name ?? 'Unknown') . "\n";
$output .= "ID: " . $mahasiswa->id . "\n\n";
// Get all approved KRS
$allKrs = $mahasiswa->krs()
->where('status', 'approved')
->with(['tahunAkademik', 'krsDetail.kelas'])
->get();
$output .= "=== KRS Records ===\n";
foreach ($allKrs as $krs) {
$output .= "KRS #{$krs->id} - TahunAkademik ID: {$krs->tahun_akademik_id} - {$krs->tahunAkademik->display_name}\n";
$output .= " KRS Detail Count: " . $krs->krsDetail->count() . "\n";
foreach ($krs->krsDetail as $detail) {
$kelas = $detail->kelas;
$output .= " - Kelas ID: {$detail->kelas_id}, Kelas Tahun: " . ($kelas->tahun_akademik_id ?? 'null') . "\n";
}
}
$output .= "\n=== Tahun Akademik ===\n";
$tahunAkademiks = TahunAkademik::orderBy('id')->get();
foreach ($tahunAkademiks as $ta) {
$output .= "ID: {$ta->id} - {$ta->display_name} - Active: " . ($ta->is_active ? 'Yes' : 'No') . "\n";
}
file_put_contents('debug_output.txt', $output);
echo "Output written to debug_output.txt\n";