prod #14

Merged
klllst merged 24 commits from develop into master 2024-06-25 21:58:29 +04:00
4 changed files with 22 additions and 1 deletions
Showing only changes of commit bcdec4dcc7 - Show all commits

View File

@ -118,4 +118,11 @@ class StudentController extends Controller
return redirect()->route('students.index');
}
public function scores(StudentService $service): View
{
return view('students.scores', [
'scores' => $service->getScores(),
]);
}
}

View File

@ -39,7 +39,7 @@ class Student extends Model
public function lessons(): BelongsToMany
{
return $this->belongsToMany(Lesson::class);
return $this->belongsToMany(Lesson::class)->withPivot('score');
}
public function scopeFilter(Builder $query): void

View File

@ -5,7 +5,9 @@ namespace App\Services;
use App\Enums\ScoreEnum;
use App\Models\Student;
use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Auth;
class StudentService
{
@ -53,4 +55,14 @@ class StudentService
$model->user()->delete();
$model->delete();
}
public function getScores(): Collection
{
$student = Auth::user()->userable;
foreach ($student->lessons as $lesson) {
dd($lesson->pivot->score);
}
return $student->lessons;
}
}

View File

@ -48,6 +48,8 @@ Route::middleware('auth')->group(function () {
});
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
Route::get('student-scores', [StudentController::class, 'scores'])->name('student-scores');
});
require __DIR__.'/auth.php';