init backend presensi

This commit is contained in:
mwpn
2026-03-05 14:37:36 +07:00
commit b4fda6b9c9
319 changed files with 27261 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class AcademicSeeder extends Seeder
{
public function run()
{
$now = date('Y-m-d H:i:s');
$todayDayOfWeek = (int) date('N'); // 1=Monday, 7=Sunday
// Insert 1 class
$classData = [
[
'name' => 'X IPA 1',
'grade' => '10',
'created_at' => $now,
'updated_at' => $now,
],
];
$this->db->table('classes')->insertBatch($classData);
$classId = $this->db->insertID();
// Insert 2 students
$studentData = [
[
'nisn' => '2024001',
'name' => 'Student One',
'gender' => 'L',
'class_id' => $classId,
'is_active' => 1,
'created_at' => $now,
'updated_at' => $now,
],
[
'nisn' => '2024002',
'name' => 'Student Two',
'gender' => 'P',
'class_id' => $classId,
'is_active' => 1,
'created_at' => $now,
'updated_at' => $now,
],
];
$this->db->table('students')->insertBatch($studentData);
// Insert 2 subjects
$subjectData = [
[
'name' => 'Mathematics',
'created_at' => $now,
'updated_at' => $now,
],
[
'name' => 'Physics',
'created_at' => $now,
'updated_at' => $now,
],
];
$this->db->table('subjects')->insertBatch($subjectData);
$subjectIds = $this->db->query('SELECT id FROM subjects ORDER BY id')->getResultArray();
$mathSubjectId = $subjectIds[0]['id'];
$physicsSubjectId = $subjectIds[1]['id'];
// Insert 1 schedule for today's weekday
// Schedule: 08:00 - 09:30 for Mathematics
$scheduleData = [
[
'class_id' => $classId,
'subject_id' => $mathSubjectId,
'teacher_name' => 'Mr. Mathematics Teacher',
'day_of_week' => $todayDayOfWeek,
'start_time' => '08:00:00',
'end_time' => '09:30:00',
'room' => 'A101',
'created_at' => $now,
'updated_at' => $now,
],
];
$this->db->table('schedules')->insertBatch($scheduleData);
}
}