- 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.
45 lines
999 B
PHP
45 lines
999 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\ClassMethod;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[Guarded(['id'])]
|
|
class CourseClass extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'method' => ClassMethod::class,
|
|
];
|
|
}
|
|
|
|
public function course(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Course::class);
|
|
}
|
|
|
|
public function lecturer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Lecturer::class);
|
|
}
|
|
|
|
public function academicTerm(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AcademicTerm::class);
|
|
}
|
|
|
|
public function enrollments(): HasMany
|
|
{
|
|
return $this->hasMany(ClassEnrollment::class);
|
|
}
|
|
}
|