<?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');
	}
}