You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InicioFilter.php 1.9KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Filters;
  3. use App\Models\PrestadorSolicitudModel;
  4. use App\Models\UserModel;
  5. use CodeIgniter\Filters\FilterInterface;
  6. use CodeIgniter\HTTP\RequestInterface;
  7. use CodeIgniter\HTTP\ResponseInterface;
  8. class InicioFilter implements FilterInterface
  9. {
  10. /**
  11. * Revisar que el usuario ya tenga su registro en la tabla prestador
  12. * De lo contrario, redireccionar a formualrio
  13. *
  14. * @param RequestInterface $request
  15. * @param array|null $arguments
  16. *
  17. * @return mixed
  18. */
  19. public function before(RequestInterface $request, $arguments = null)
  20. {
  21. // Usuario no cuenta tiene asignado un registro en `prestador`
  22. if (!user()->idprestador) {
  23. // Usuario no ha registrado sus datos por primera vez
  24. if (!user()->rh_prestador_solicitud_id) {
  25. return redirect('registro');
  26. }
  27. // Ya registr� sus datos, est� pendiente la aprobaci�n de RH
  28. // Ver status de la solicitud
  29. $status = model(PrestadorSolicitudModel::class)->find(user()->rh_prestador_solicitud_id)['status'];
  30. if ($status == 0) // aún no ha sido aprobada
  31. return \Config\Services::response()->setBody(view('Prestador/success'));
  32. else if ($status == 2)
  33. return \Config\Services::response()->setBody(view('Prestador/registroNoAprobado'));
  34. }
  35. }
  36. /**
  37. * Allows After filters to inspect and modify the response
  38. * object as needed. This method does not allow any way
  39. * to stop execution of other after filters, short of
  40. * throwing an Exception or Error.
  41. *
  42. * @param RequestInterface $request
  43. * @param ResponseInterface $response
  44. * @param array|null $arguments
  45. *
  46. * @return mixed
  47. */
  48. public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
  49. {
  50. //
  51. }
  52. }