1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Http\Controllers;
- use App\Repositories\Enums\ResponseCodeEnum;
- use Illuminate\Support\Facades\Log;
- use Jiannei\Response\Laravel\Support\Facades\Response;
- use Jiannei\Response\Laravel\Support\Traits\ExceptionTrait;
- use Laravel\Lumen\Routing\Controller as BaseController;
- abstract class Controller extends BaseController
- {
- use ExceptionTrait;
- const PAGE_NUM = 15;
- public function exception(\Exception $exception)
- {
- Log::error($exception);
- if (config('app.env') == 'production') {
- Response::fail(T('An unknown error was encountered.'), ResponseCodeEnum::SYSTEM_ERROR);
- } else {
- Response::fail($exception->getMessage(), ResponseCodeEnum::SYSTEM_ERROR);
- }
- }
- public function notFound()
- {
- Response::fail('The resource could not be found.', ResponseCodeEnum::SERVICE_NOT_FIND_DATA_ERROR);
- }
- public function errorStore($exception)
- {
- Log::error($exception);
- if (config('app.env') == 'production') {
- Response::fail(T('An unknown error was encountered.'), ResponseCodeEnum::SYSTEM_ERROR);
- } else {
- Response::fail($exception->getMessage(), ResponseCodeEnum::SYSTEM_ERROR);
- }
- }
- public function errorFail()
- {
- return Response::fail(T('The operation failure.'), ResponseCodeEnum::SERVICE_UPDATE_DATA_ERROR);
- }
- }
|