61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace App\Filters;
|
||
|
||
use App\Models\PrestadorSolicitudModel;
|
||
use App\Models\UserModel;
|
||
use CodeIgniter\Filters\FilterInterface;
|
||
use CodeIgniter\HTTP\RequestInterface;
|
||
use CodeIgniter\HTTP\ResponseInterface;
|
||
|
||
|
||
class InicioFilter implements FilterInterface
|
||
{
|
||
/**
|
||
* Revisar que el usuario ya tenga su registro en la tabla prestador
|
||
* De lo contrario, redireccionar a formualrio
|
||
*
|
||
* @param RequestInterface $request
|
||
* @param array|null $arguments
|
||
*
|
||
* @return mixed
|
||
*/
|
||
public function before(RequestInterface $request, $arguments = null)
|
||
{
|
||
// Usuario no cuenta tiene asignado un registro en `prestador`
|
||
if (!user()->idprestador) {
|
||
|
||
// Usuario no ha registrado sus datos por primera vez
|
||
if (!user()->rh_prestador_solicitud_id) {
|
||
return redirect('registro');
|
||
}
|
||
|
||
// Ya registr<74> sus datos, est<73> pendiente la aprobaci<63>n de RH
|
||
|
||
// Ver status de la solicitud
|
||
$status = model(PrestadorSolicitudModel::class)->find(user()->rh_prestador_solicitud_id)['status'];
|
||
if ($status == 0) // aún no ha sido aprobada
|
||
return \Config\Services::response()->setBody(view('Prestador/success'));
|
||
else if ($status == 2)
|
||
return \Config\Services::response()->setBody(view('Prestador/registroNoAprobado'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Allows After filters to inspect and modify the response
|
||
* object as needed. This method does not allow any way
|
||
* to stop execution of other after filters, short of
|
||
* throwing an Exception or Error.
|
||
*
|
||
* @param RequestInterface $request
|
||
* @param ResponseInterface $response
|
||
* @param array|null $arguments
|
||
*
|
||
* @return mixed
|
||
*/
|
||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||
{
|
||
//
|
||
}
|
||
}
|