Files
cachet-docker/app/start/global.php
2015-02-27 01:19:29 -06:00

79 lines
2.5 KiB
PHP

<?php
use Dingo\Api\Facade\API;
use Illuminate\Support\Facades\Log;
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path().'/logs/laravel.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
Log::error($exception);
});
API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
return Response::make(['error' => $exception->getMessage()], 404);
});
API::error(function (\CachetHQ\Cachet\Repositories\InvalidModelValidationException $exception) {
return Response::make(['status_code' => 400, 'message' => 'Bad Request'], 400);
});
App::missing(function ($exception) {
if (Request::is('dashboard*') or Request::is('api*')) {
return Response::view('errors.404', [
'pageTitle' => trans('cachet.dashboard.not_found_title'),
], 404);
}
return Redirect::route('status-page');
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/
App::down(function () {
return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Analytics
|--------------------------------------------------------------------------
|
| We handle all Segment.com tracking here. The function call will only do
| something if tracking is enabled.
|
*/
segment_identify();