20 lines
437 B
PHP
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;
|
|
}
|
|
}
|