CustomScheduleSpecialityService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Services;
  3. use App\Models\CustomScheduleSpeciality;
  4. class CustomScheduleSpecialityService
  5. {
  6. public function getAll()
  7. {
  8. return CustomScheduleSpeciality::with(['customSchedule', 'speciality'])
  9. ->orderBy('created_at', 'desc')
  10. ->get();
  11. }
  12. public function getById($id)
  13. {
  14. return CustomScheduleSpeciality::with(['customSchedule', 'speciality'])->findOrFail($id);
  15. }
  16. public function getByCustomScheduleId($customScheduleId)
  17. {
  18. return CustomScheduleSpeciality::with(['speciality'])
  19. ->where('custom_schedule_id', $customScheduleId)
  20. ->get();
  21. }
  22. public function create(array $data)
  23. {
  24. return CustomScheduleSpeciality::create($data);
  25. }
  26. public function update($id, array $data)
  27. {
  28. $customScheduleSpeciality = CustomScheduleSpeciality::findOrFail($id);
  29. $customScheduleSpeciality->update($data);
  30. return $customScheduleSpeciality->fresh(['customSchedule', 'speciality']);
  31. }
  32. public function delete($id)
  33. {
  34. $customScheduleSpeciality = CustomScheduleSpeciality::findOrFail($id);
  35. $customScheduleSpeciality->delete();
  36. return $customScheduleSpeciality;
  37. }
  38. }