Enhance Group and Document resources; add leader and helper teacher relationships, update navigation icons, and adjust navigation sorting.
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
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;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property date $start_date
|
||||
* @property date $end_date
|
||||
* @property Pilgrim[] $pilgrims
|
||||
@@ -22,4 +23,14 @@ class Group extends Model
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class);
|
||||
}
|
||||
|
||||
public function leaderTeacher(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Teacher::class, 'leader_teacher_id');
|
||||
}
|
||||
|
||||
public function helperTeachers(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Teacher::class, 'group_teacher');
|
||||
}
|
||||
}
|
||||
|
||||
24
app/Models/Teacher.php
Normal file
24
app/Models/Teacher.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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\HasMany;
|
||||
|
||||
class Teacher extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\TeacherFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public function ledGroups(): HasMany
|
||||
{
|
||||
return $this->hasMany(Group::class, 'leader_teacher_id');
|
||||
}
|
||||
|
||||
public function assistedGroups(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Group::class, 'group_teacher');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user