GuestController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Appointment;
  4. use App\Models\CareMonth;
  5. use App\Models\CareMonthEntry;
  6. use App\Models\Client;
  7. use App\Models\Handout;
  8. use App\Models\HandoutClient;
  9. use App\Models\Pro;
  10. use App\Models\Section;
  11. use App\Models\SectionTemplate;
  12. use Illuminate\Http\Request;
  13. use Illuminate\Support\Facades\File;
  14. use Illuminate\Support\Facades\Response;
  15. class GuestController extends Controller
  16. {
  17. public function section(Request $request, $guestAccessCode )
  18. {
  19. $section = Section::where('guest_access_code', $guestAccessCode)->first();
  20. abort_if(!$section, 404, 'Invalid access code');
  21. abort_if(!$section->is_active, 404, 'Invalid access code');
  22. abort_if($section->guest_access_level == 'NONE', 401, 'Invalid access code');
  23. $patient = null;
  24. if($section->note){
  25. $patient = $section->note->client;
  26. }else{
  27. $patient = $section->client;
  28. }
  29. return view('app.guest.section', compact('patient','section', 'guestAccessCode'));
  30. }
  31. public function handout(Request $request, $handoutClientUid )
  32. {
  33. $handoutClient = HandoutClient::where('uid', $handoutClientUid)->first();
  34. abort_if((!$handoutClient || !$handoutClient->is_active), 404, 'Invalid access code');
  35. $handout = Handout::where('id', $handoutClient->handout_id)->first();
  36. abort_if((!$handout || !$handout->is_active), 404, 'Invalid access code');
  37. return Response::download(
  38. $handout->pdf_file_path,
  39. $handout->internal_name . '.pdf',
  40. ['Content-Type: application/pdf']
  41. );
  42. }
  43. public function appointmentConfirmation(Request $request, $appointmentUid )
  44. {
  45. $appointment = Appointment::where('uid', $appointmentUid)->first();
  46. abort_if(!count($appointment->confirmationRequests), 404, 'No confirmation requests on this appointment.');
  47. abort_if(!$appointment, 404, 'Invalid url');
  48. abort_if($appointment->status == 'CANCELLED', 404, 'Appointment has been cancelled');
  49. abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed');
  50. abort_if($appointment->status == 'ABANDONED', 404, 'Appointment has been abandoned');
  51. return view('app.guest.appointment-confirmation', compact('appointment'));
  52. }
  53. }