- Implemented ClassEnrollmentIndex component for managing class enrollments, including adding and removing students. - Created CourseClassIndex component for managing course classes with CRUD functionality. - Developed columns for course management in createCourseColumns function. - Added CourseIndex component for managing courses with CRUD operations. - Introduced types for class enrollment and course class to enhance type safety. - Updated routes to include endpoints for managing courses, course classes, and enrollments.
32 lines
646 B
PHP
32 lines
646 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Guarded(['id'])]
|
|
class ClassEnrollment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'enrolled_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function courseClass(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CourseClass::class);
|
|
}
|
|
|
|
public function student(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Student::class);
|
|
}
|
|
}
|