This repository has been archived on 2026-09-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tutoring/app/Models/TeacherProfile.php
2026-01-14 00:54:08 +00:00

59 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class TeacherProfile extends Model
{
// Which attributes can be mass-assigned (used in ::create([...]))
protected $fillable = [
'user_id',
'bio',
'picture',
'location',
'hourly_rate',
'qualifications',
'active',
];
/**
* Link back to the user this profile belongs to
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Subjects this teacher teaches
*/
public function subjects(): BelongsToMany
{
return $this->belongsToMany(Subject::class, 'level_subject_teacher')
->withPivot('level_id'); // since we’re also tracking level
}
/**
* Levels this teacher teaches
*/
public function levels(): BelongsToMany
{
return $this->belongsToMany(Level::class, 'level_subject_teacher')
->withPivot('subject_id');
}
public function teachingArrangements(): HasMany
{
return $this->hasMany(TeachingArrangement::class, 'teacher_id');
}
public function payPeriods(): HasMany
{
return $this->hasMany(TeacherPayPeriod::class, 'teacher_id');
}
}