李帅

init

......@@ -3,10 +3,13 @@
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Jiannei\Response\Laravel\Support\Traits\ExceptionTrait;
use Throwable;
class Handler extends ExceptionHandler
{
use ExceptionTrait;
/**
* A list of the exception types that are not reported.
*
......
......@@ -40,8 +40,8 @@ class Kernel extends HttpKernel
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
// 'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
......
......@@ -9,6 +9,8 @@
"dcat/laravel-admin": "2.*",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"jiannei/laravel-enum": "^3.0",
"jiannei/laravel-response": "^4.0",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/socialite": "^5.2",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "049d4f5ac63a95630253c84eb084183e",
"content-hash": "298c2071717850e70431d14a67202770",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -1557,6 +1557,171 @@
"time": "2021-10-06T17:43:30+00:00"
},
{
"name": "jiannei/helpers",
"version": "v0.2.1",
"source": {
"type": "git",
"url": "https://github.com/Jiannei/helpers.git",
"reference": "1fa669201e3c4f9b384ffdb5ab3ea4caabc594f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jiannei/helpers/zipball/1fa669201e3c4f9b384ffdb5ab3ea4caabc594f3",
"reference": "1fa669201e3c4f9b384ffdb5ab3ea4caabc594f3",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"type": "library",
"autoload": {
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "jiannei",
"email": "longjian.huang@foxmail.com"
}
],
"description": "Some helper functions.",
"support": {
"issues": "https://github.com/Jiannei/helpers/issues",
"source": "https://github.com/Jiannei/helpers/tree/v0.2.1"
},
"time": "2021-06-16T03:01:10+00:00"
},
{
"name": "jiannei/laravel-enum",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/Jiannei/laravel-enum.git",
"reference": "a3686fda3cf6c51942d13a50bdcd5f41622907b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jiannei/laravel-enum/zipball/a3686fda3cf6c51942d13a50bdcd5f41622907b2",
"reference": "a3686fda3cf6c51942d13a50bdcd5f41622907b2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-json": "*",
"jiannei/helpers": "^0.2.1"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Jiannei\\Enum\\Laravel\\Providers\\LaravelServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Jiannei\\Enum\\Laravel\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "jiannei",
"email": "longjian.huang@foxmail.com"
}
],
"description": "A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently, supporting Laravel and Lumen",
"support": {
"issues": "https://github.com/Jiannei/laravel-enum/issues",
"source": "https://github.com/Jiannei/laravel-enum/tree/v3.0.0"
},
"time": "2021-09-19T14:27:22+00:00"
},
{
"name": "jiannei/laravel-response",
"version": "v4.1.0",
"source": {
"type": "git",
"url": "https://github.com/Jiannei/laravel-response.git",
"reference": "5193800903dd677a02bb43b586bbdf2f6f342eea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jiannei/laravel-response/zipball/5193800903dd677a02bb43b586bbdf2f6f342eea",
"reference": "5193800903dd677a02bb43b586bbdf2f6f342eea",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^7.2.5|^8.0"
},
"require-dev": {
"jiannei/laravel-enum": "^3.0",
"laravel/legacy-factories": "^1.1",
"league/fractal": "^0.19.2",
"orchestra/database": "^6.0",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Jiannei\\Response\\Laravel\\Providers\\LaravelServiceProvider"
],
"aliases": {
"Response": "Jiannei\\Response\\Laravel\\Support\\Facades\\Response"
}
}
},
"autoload": {
"psr-4": {
"Jiannei\\Response\\Laravel\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "jiannei",
"email": "longjian.huang@foxmail.com"
}
],
"description": "Laravel api response data format.",
"support": {
"issues": "https://github.com/Jiannei/laravel-response/issues",
"source": "https://github.com/Jiannei/laravel-response/tree/v4.1.0"
},
"time": "2021-12-24T08:17:43+00:00"
},
{
"name": "laravel/framework",
"version": "v8.77.1",
"source": {
......
......@@ -40,6 +40,10 @@ return [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'one_users',
]
],
/*
......@@ -69,6 +73,10 @@ return [
// 'driver' => 'database',
// 'table' => 'users',
// ],
'one_users' => [
'driver' => 'eloquent',
'model' => App\Models\OneUser::class,
]
],
/*
......
<?php
/*
* This file is part of the Jiannei/laravel-enum.
*
* (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.
*/
return [
'localization' => [
'key' => env('ENUM_LOCALIZATION_KEY', 'enums'),
],
// 你可以将请求参数中用到的枚举定义在下面,通过中间件,将会被自动转换成枚举类
'transformations' => [
// 参数名 => 对应的枚举类
],
];
<?php
/*
* This file is part of the Jiannei/laravel-response.
*
* (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.
*/
return [
/*
|--------------------------------------------------------------------------
| Set the http status code when the response fails
|--------------------------------------------------------------------------
|
| the reference options are false, 200, 500
|
| false, stricter http status codes such as 404, 401, 403, 500, etc. will be returned
| 200, All failed responses will also return a 200 status code
| 500, All failed responses return a 500 status code
*/
'error_code' => false,
// You can use enumerations to define the code when the response is returned,
// and set the response message according to the locale
//
// The following two enumeration packages are good choices
//
// https://github.com/Jiannei/laravel-enum
// https://github.com/BenSampo/laravel-enum
// 'enum' => '', // \Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum::class
'enum' => \Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum::class, //
// You can set some attributes (eg:code/message/header/options) for the exception, and it will override the default attributes of the exception
'exception' => [
\Illuminate\Validation\ValidationException::class => [
'code' => 422,
],
\Illuminate\Auth\AuthenticationException::class => [
'message' => '用户未登录'
],
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class =>[
'message' => '',
],
\Illuminate\Database\Eloquent\ModelNotFoundException::class => [
'message' => '',
],
],
// Set the structure of the response data
'format' => [
'fields' => [
'status' => ['alias' => 'status', 'show' => true],
'code' => ['alias' => 'code', 'show' => true],
'message' => ['alias' => 'message', 'show' => true],
'error' => ['alias' => 'error', 'show' => true],
'data' => [
'alias' => 'data',
'show' => true,
'fields' => [
// When data is nested with data, such as returning paged data, you can also set an alias for the inner data
'data' => ['alias' => 'data', 'show' => true], // data/rows/list
'meta' => [
'alia' => 'meta',
'show' => true,
'fields' => [
'pagination' => [
'alias' => 'pagination',
'show' => true,
'fields' => [
'total' => ['alias' => 'total', 'show' => true],
'count' => ['alias' => 'count', 'show' => true],
'per_page' => ['alias' => 'per_page', 'show' => true],
'current_page' => ['alias' => 'current_page', 'show' => true],
'total_pages' => ['alias' => 'total_pages', 'show' => true],
'links' => [
'alias' => 'links',
'show' => true,
'fields' => [
'previous' => ['alias' => 'previous', 'show' => true],
'next' => ['alias' => 'next', 'show' => true],
],
],
],
],
],
],
],
],
],
],
];
......@@ -31,7 +31,7 @@ return [
|
*/
'guard' => ['web'],
'guard' => ['web','api'],
/*
|--------------------------------------------------------------------------
......
......@@ -14,6 +14,8 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
//Route::prefix('v1')->middleware('auth:sanctum')->group(function ($api){
Route::prefix('v1')->group(function ($api){
});
\ No newline at end of file
......