CustomScheduleSpecialityService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 create(array $data)
  17. {
  18. return CustomScheduleSpeciality::create($data);
  19. }
  20. public function update($id, array $data)
  21. {
  22. $customScheduleSpeciality = CustomScheduleSpeciality::findOrFail($id);
  23. $customScheduleSpeciality->update($data);
  24. return $customScheduleSpeciality->fresh(['customSchedule', 'speciality']);
  25. }
  26. public function delete($id)
  27. {
  28. $customScheduleSpeciality = CustomScheduleSpeciality::findOrFail($id);
  29. $customScheduleSpeciality->delete();
  30. return $customScheduleSpeciality;
  31. }
  32. //
  33. public function getByCustomScheduleId($customScheduleId)
  34. {
  35. return CustomScheduleSpeciality::with(['speciality'])
  36. ->where('custom_schedule_id', $customScheduleId)
  37. ->get();
  38. }
  39. }