siakad-itm/app/Models/Lecturer.php
Yoga Pangestu 07a00a92a2
Some checks failed
tests / ci (pull_request) Has been cancelled
Refactor lecturer management to support multiple departments
- Updated LecturerController to load multiple departments for lecturers.
- Modified LecturerRequest to accept an array of department IDs instead of a single department ID.
- Changed Department model to establish a many-to-many relationship with Lecturer.
- Adjusted Lecturer model to reflect the new many-to-many relationship with Department.
- Updated LecturerService to handle multiple departments during creation and updates.
- Created LecturerFactory and StudentFactory for generating test data.
- Added a migration for the new lecturer_department pivot table.
- Refactored seeder classes to accommodate the new structure for lecturers and departments.
- Enhanced frontend components for creating and editing lecturers to support multiple department selection.
2026-08-30 12:18:13 +07:00

43 lines
1.0 KiB
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;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
#[Guarded(['id'])]
class Lecturer extends Model
{
use HasFactory, SoftDeletes;
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function departments(): BelongsToMany
{
return $this->belongsToMany(Department::class, 'lecturer_department');
}
public function advisees(): HasMany
{
return $this->hasMany(Student::class, 'academic_advisor_id');
}
public function leaderships(): HasMany
{
return $this->hasMany(DepartmentLeadership::class);
}
public function academicAdvisingLogs(): HasMany
{
return $this->hasMany(AcademicAdvisingLog::class);
}
}