36 lines
732 B
PHP
36 lines
732 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
class Teacher extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'last_name',
|
|
'middle_name',
|
|
'birthday',
|
|
];
|
|
|
|
public function subjects(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Subject::class);
|
|
}
|
|
|
|
public function grades(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Grade::class);
|
|
}
|
|
|
|
public function user(): MorphOne
|
|
{
|
|
return $this->morphOne(User::class, 'userable');
|
|
}
|
|
}
|