CourseWork/app/Services/ScoreService.php

37 lines
793 B
PHP
Raw Normal View History

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