From bd03c095fc46984cda1cfdc768559759aebd1c86 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Wed, 12 Oct 2022 13:43:33 +0800 Subject: [PATCH] config/admin.php --- README.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ config/admin.php | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ceea38..1b5a4b0 100755 --- a/README.md +++ b/README.md @@ -100,3 +100,73 @@ protected function renderBack() HTML; } ``` + +## 配置 + +- config/app.php + +```php +return [ + 'timezone' => env('TIMEZONE', 'Asia/Chongqing'), + 'locale' => 'zh_CN', +]; +``` + +- config/auth.php + +```php +return [ + 'api' => [ + 'driver' => 'sanctum', + 'provider' => 'users', + ], + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => Peidikeji\User\Models\User::class, + ], + ], +]; +``` + +- app\Exceptions\Handler.php + +```php +public function register() +{ + $this->renderable(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e, Request $request) { + if ($request->ajax()) { + return response()->json(['code' => 404, 'message' => $e->getMessage(), 'data' => null], 200); + } + }); + $this->renderable(function (\Illuminate\Validation\ValidationException $e, Request $request) { + if ($request->ajax()) { + $errors = $e->validator->errors(); + return response()->json(['code' => 422, 'message' => $errors->first(), 'data' => $errors], 200); + } + }); +} +``` + +- app\Http\Controllers\Controller.php + +```php +use Dcat\Admin\Traits\JsonResponse; + +use Illuminate\Routing\Controller as BaseController; +class Controller extends BaseController +{ + use JsonResponse; +} +``` + +- app\Providers\RouteServiceProvider.php + +```php +protected function configureRateLimiting() +{ + RateLimiter::for('sms', function (Request $request) { + return Limit::perMinute(1)->by($request->input('phone')); + }); +} +``` diff --git a/config/admin.php b/config/admin.php index f8366a4..5904e61 100755 --- a/config/admin.php +++ b/config/admin.php @@ -114,7 +114,7 @@ return [ | If your page is going to be accessed via https, set it to `true`. | */ - 'https' => env('ADMIN_HTTPS', false), + 'https' => \Illuminate\Support\Str::startsWith(env('APP_URL'), 'https://'), /* |--------------------------------------------------------------------------