prod #14
@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user