4
0
Fork 0

config/admin.php

master
panliang 2022-10-12 13:43:33 +08:00
parent 158f3f9b58
commit bd03c095fc
2 changed files with 71 additions and 1 deletions

View File

@ -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'));
});
}
```

View File

@ -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://'),
/*
|--------------------------------------------------------------------------