Exemplo n.º 1
0
 /**
  * 
  * Contructor de la clase.
  * 
  * @param string $file Contiene el archivo donde fue lanzada la excepción.
  * @param string $message Contiene el mensaje a guardar en el log.
  * @param int $httpCode Contiene el código http a enviar al usuario.
  * @param array $response Contiene el array a ser enviado al usuario.
  * 
  */
 function __construct($file, $message, $httpCode, $response = [])
 {
     Log::addException($file, $message, $httpCode);
     $this->code = $httpCode;
     $this->response = array_merge(['error' => true, 'httpCode' => $httpCode], $response);
     parent::__construct($message, $this->getCode());
 }
Exemplo n.º 2
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     // var_dump($e -> errorInfo[1]);
     if ($e instanceof \Core\Exception\RestException) {
         return response()->json($e->getResponse(), $e->getCode());
     }
     // var_dump($e);
     // if ($e instanceof ModelNotFoundException) {
     //     $e = new NotFoundHttpException($e->getMessage(), $e);
     // }
     if ($e instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) {
         Log::addException(__FILE__, $e->getMessage(), $e->getStatusCode());
         return response()->json(['error' => true, 'httpCode' => $e->getStatusCode(), 'type' => 'MethodNotAllowedHttpException'], $e->getStatusCode());
     }
     if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
         Log::addException(__FILE__, $e->getMessage(), $e->getStatusCode());
         return response()->json(['error' => true, 'httpCode' => $e->getStatusCode(), 'type' => 'NotFoundHttpException'], $e->getStatusCode());
     }
     if ($e instanceof \PDOException) {
         Log::addException(__FILE__, $e->getMessage(), $e->getCode());
         $message = "";
         if ($e->errorInfo[1] == 1062) {
             $message = "Elemento duplicado.";
         }
         return response()->json(['error' => true, 'httpCode' => 500, 'type' => 'PDOException', 'message' => $message], 409);
     }
     return parent::render($request, $e);
     // return response()->json(['error' => true, 'type' => 'desconocido', 'message' => $e -> getMessage()], 500);
 }
Exemplo n.º 3
0
|
*/
Route::get('/', function () {
    echo "Bienvenido";
});
Route::post('logIn', ['uses' => 'SysControllers\\LogController@logIn']);
Route::group(['middleware' => 'auth.user'], function () {
    Route::get('ip', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\IpController@all']);
    Route::post('ip', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\IpController@add']);
    Route::delete('ip/{id}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\IpController@delete']);
    Route::get('servicio', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\ServicioController@all']);
    Route::get('servicio/{id}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\ServicioController@one']);
    Route::post('servicio', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\ServicioController@add']);
    Route::put('servicio/{id}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\ServicioController@update']);
    //falta
    Route::delete('servicio/{id}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\ServicioController@delete']);
    Route::get('registros/novalidados', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\RegistrosController@allNoValidate']);
    Route::get('servicio/{id}/registros', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\RegistrosController@all']);
    Route::put('servicio/{idS}/registros/{idR}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\RegistrosController@update']);
    Route::delete('servicio/{idS}/registros/{idR}', ['middleware' => 'authorize.user:admin', 'uses' => 'SysControllers\\RegistrosController@delete']);
    Route::get('servicio/current/who', ['middleware' => 'authorize.user:servicio', 'uses' => 'SysControllers\\RegistroServController@who']);
    Route::get('servicio/current/status', ['middleware' => 'authorize.user:servicio', 'uses' => 'SysControllers\\RegistroServController@getStatus']);
    Route::post('servicio/current/inicio', ['middleware' => 'authorize.user:servicio', 'uses' => 'SysControllers\\RegistroServController@ini']);
    Route::post('servicio/current/fin', ['middleware' => 'authorize.user:servicio', 'uses' => 'SysControllers\\RegistroServController@fin']);
    Route::get('servicio/current/ownregistros', ['middleware' => 'authorize.user:servicio', 'uses' => 'SysControllers\\RegistroServController@all']);
});
use Core\Log\Log;
Event::listen('illuminate.query', function ($query, $bindings, $time, $name) {
    $data = ["time" => $time, "query" => $query, "bindings" => $bindings];
    Log::addDebug($name, $data);
});