CourseWork/app/Services/ScoreService.php
2024-06-17 17:38:29 +04:00

20 lines
437 B
PHP

<?php
namespace App\Services;
use App\Models\Lesson;
class ScoreService
{
public function update(Lesson $lesson, array $data)
{
$lesson->students->each(function ($item, $key) use ($data, $lesson) {
if ($data['score' . $item->id]) {
$lesson->students()->syncWithoutDetaching([$item->id => ['score' => $data['score' . $item->id]]]);
}
});
return $lesson;
}
}