CourseWork/app/Services/ScoreService.php
m.zargarov 92efb4498d Fixed
2024-05-27 16:57:28 +04:00

37 lines
793 B
PHP

<?php
namespace App\Services;
use App\Models\Lesson;
use Illuminate\Database\Eloquent\Model;
class ScoreService implements ServiceInterface
{
public function getAll(?Lesson $lesson = null)
{
return $lesson->students;
}
public function update(Model $model, array $data)
{
$model->students->each(function ($item, $key) use ($data, $model) {
if ($data['score' . $item->id]) {
$model->students()->syncWithoutDetaching([$item->id => ['score' => $data['score' . $item->id]]]);
}
});
return $model;
}
public function delete(Model $model)
{
// TODO: Implement delete() method.
}
public function create(array $data)
{
// TODO: Implement create() method.
}
}