prod #7

Merged
klllst merged 40 commits from feature/task-7 into master 2024-06-16 12:25:52 +04:00
4 changed files with 33 additions and 0 deletions
Showing only changes of commit 08f5909a9f - Show all commits

View File

@ -31,6 +31,11 @@ class Grade extends Model
return $this->belongsToMany(Teacher::class);
}
public function lessons(): HasMany
{
return $this->hasMany(Lesson::class);
}
public function scopeFilter(Builder $query): void
{
$name = request('name');

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Lesson extends Model
@ -20,4 +21,19 @@ class Lesson extends Model
{
return $this->hasMany(Score::class);
}
public function grades(): BelongsTo
{
return $this->belongsTo(Grade::class);
}
public function teachers(): BelongsTo
{
return $this->belongsTo(Teacher::class);
}
public function subjects(): BelongsTo
{
return $this->belongsTo(Subject::class);
}
}

View File

@ -6,6 +6,7 @@ use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
class Subject extends Model
@ -31,6 +32,11 @@ class Subject extends Model
return $this->belongsToMany(Student::class)->using(Score::class);
}
public function lessons(): HasMany
{
return $this->hasMany(Lesson::class);
}
public function scopeFilter(Builder $query): void
{
$name = request('name');

View File

@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
class Teacher extends Model
@ -35,6 +36,11 @@ class Teacher extends Model
return $this->morphOne(User::class, 'userable');
}
public function lessons(): HasMany
{
return $this->hasMany(Lesson::class);
}
public function scopeFilter(Builder $query): void
{
$name = request('name');