切换为 lumen

This commit is contained in:
iVampireSP.com 2022-09-09 00:12:02 +08:00
parent e9f151fa04
commit 5b587bb9d2
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
142 changed files with 3860 additions and 7621 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -13,6 +13,3 @@ trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

View File

@ -1,62 +1,18 @@
APP_NAME=Laravel
APP_NAME=Lumen
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lae
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
ALIPAY_APP_ID=
OCTANE_HTTPS=false

11
.gitattributes vendored
View File

@ -1,11 +0,0 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

18
.gitignore vendored
View File

@ -1,18 +1,6 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
/.idea
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.idea
/.vscode
rr
.rr.yaml
.env
.phpunit.result.cache

6
.styleci.yml Normal file
View File

@ -0,0 +1,6 @@
php:
preset: laravel
disabled:
- unused_use
js: true
css: true

View File

@ -1,64 +1,24 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
# Lumen PHP Framework
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework)
[![Total Downloads](https://img.shields.io/packagist/dt/laravel/lumen-framework)](https://packagist.org/packages/laravel/lumen-framework)
[![Latest Stable Version](https://img.shields.io/packagist/v/laravel/lumen-framework)](https://packagist.org/packages/laravel/lumen-framework)
[![License](https://img.shields.io/packagist/l/laravel/lumen)](https://packagist.org/packages/laravel/lumen-framework)
## About Laravel
Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
## Official Documentation
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
Documentation for the framework can be found on the [Lumen website](https://lumen.laravel.com/docs).
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
Thank you for considering contributing to Lumen! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -2,16 +2,24 @@
namespace App\Console;
use App\Jobs\HostCost;
use App\Jobs\ClearTasks;
use App\Jobs\DeleteHost;
use App\Jobs\Remote;
use App\Jobs\HostCost;
use App\Jobs\UserSave;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
@ -20,7 +28,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
//
// dispatch HostCost job
$schedule->job(new HostCost())->withoutOverlapping()->everyFiveMinutes();
@ -32,19 +40,5 @@ protected function schedule(Schedule $schedule)
$schedule->job(new ClearTasks())->weekly();
$schedule->job(new DeleteHost())->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

10
app/Events/Event.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App\Events;
use Illuminate\Queue\SerializesModels;
abstract class Event
{
use SerializesModels;
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Events;
class ExampleEvent extends Event
{
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
}

View File

@ -2,49 +2,53 @@
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
* A list of the exception types that should not be reported.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
* @var array
*/
protected $dontReport = [
//
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
* Report or log an exception.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function register()
public function report(Throwable $exception)
{
$this->reportable(function (Throwable $e) {
//
});
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}

8
app/Helpers.php Normal file
View File

@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Carbon;
function now($timezone = null)
{
return Carbon::now($timezone);
}

View File

@ -57,7 +57,7 @@ public function show(Admin $admin)
*/
public function update(Request $request, Admin $admin)
{
//
//
$admin->update($request->all());
return $this->updated($admin);

View File

@ -38,7 +38,7 @@ public function index(Request $request)
*/
public function store(Request $request, Host $host)
{
$request->validate([
$this->validate($request, [
'name' => 'required|max:255',
'module_id' => 'required|string|exists:modules,id',
'price' => 'required|numeric',
@ -48,7 +48,7 @@ public function store(Request $request, Host $host)
if ($request->route('user')) {
$user_id = $request->route('user');
} else {
$request->validate([
$this->validate($request, [
'user_id' => 'required|integer|exists:users,id',
]);
$user_id = $request->user_id;

View File

@ -28,7 +28,7 @@ public function index(Drop $drop)
public function store(Request $request)
{
//
$request->validate([
$this->validate($request, [
'amount' => 'integer|required|min:1|max:1000',
]);

View File

@ -33,7 +33,7 @@ public function index(WorkOrder $work_order)
public function store(Request $request)
{
//
$request->validate([
$this->validate($request, [
'title' => 'required|max:255',
'host_id' => 'required|integer|exists:hosts,id',
'content' => 'required|max:255',

View File

@ -2,16 +2,9 @@
namespace App\Http\Controllers;
// use App\Helpers\ApiResponse;
use App\Models\User;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
// use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class AuthController extends Controller
{
@ -20,191 +13,13 @@ class AuthController extends Controller
public function index(Request $request)
{
// test
// $handle = new \App\Jobs\Remote\PushHost();
// $handle->handle();
// $handle = new \App\Jobs\Remote\PushWorkOrder();
// $handle->handle();
// if logged in
// auth check
if (Auth::check()) {
$token_name = 'login token ' . now()->toDateString();
$token = $request->user()->createToken($token_name, ['user:login'])->plainTextToken;
if ($request->callback) {
return redirect($request->callback . '?token=' . $token);
} else if ($request->getToken) {
return $this->created($token);
} else {
return view('index');
}
dd(Auth::user());
} else {
// save callback url and referer url to session
session(['callback' => $request->callback]);
return redirect()->route('login');
}
}
public function redirect(Request $request)
{
$request->session()->put('state', $state = Str::random(40));
$query = http_build_query([
'client_id' => config('oauth.client_id'),
'redirect_uri' => config('oauth.callback_uri'),
'response_type' => 'code',
'scope' => '',
'state' => $state,
'meta' => 'test_meta',
]);
// dd($query);
return redirect()->to(config('oauth.oauth_auth_url') . '?' . $query);
}
public function callback(Request $request)
{
$state = $request->session()->pull('state');
if (!strlen($state) > 0 && $state === $request->state) {
return redirect(route('login'));
dd('n');
}
$http = new Client();
try {
$authorize = $http->post(config('oauth.oauth_token_url'), [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => config('oauth.client_id'),
'client_secret' => config('oauth.client_secret'),
'redirect_uri' => config('oauth.callback_uri'),
'code' => $request->code,
],
])->getBody();
} catch (ClientException) {
return redirect(route('login'));
}
$authorize = json_decode($authorize);
$oauth_user = $http->get(config('oauth.oauth_user_url'), [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $authorize->access_token,
],
])->getBody();
$oauth_user = json_decode($oauth_user);
$user_sql = User::where('email', $oauth_user->email);
$user = $user_sql->first();
if (is_null($user)) {
$name = $oauth_user->name;
$email = $oauth_user->email;
$email_verified_at = $oauth_user->email_verified_at;
$user = User::create([
'name' => $name,
'email' => $email,
'password' => null,
'email_verified_at' => $email_verified_at,
'oauth_id' => $oauth_user->id,
'provider' => 'LoliArt',
'provider_id' => $oauth_user->id,
'real_name' => $oauth_user->real_name,
'balance' => 1
]);
$request->session()->put('auth.password_confirmed_at', time());
} else {
if ($user->name != $oauth_user->name) {
User::where('email', $oauth_user->email)->update([
'name' => $oauth_user->name
]);
}
// $api_token = $user->api_token;
}
Auth::loginUsingId($user->id, true);
return redirect()->route('index', ['callback' => session('callback')]);
}
public function reset()
{
return view('password.reset');
}
public function setup_password(Request $request)
{
$request->validate([
'password' => 'required',
]);
User::find(auth()->id())->update(['password' => Hash::make($request->password)]);
return redirect()->route('main.index');
}
public function confirm()
{
return view('password.confirm');
}
public function confirm_password(Request $request)
{
$request->validate($this->password_rules());
$request->session()->put('auth.password_confirmed_at', time());
return $request->wantsJson()
? new JsonResponse([], 204)
: redirect()->intended($this->redirectPath());
}
protected function password_rules()
{
return [
'password' => 'required|password',
];
}
public function redirectPath()
{
if (method_exists($this, 'redirectTo')) {
return $this->redirectTo();
}
return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
}
public function createApiToken(Request $request)
{
$request->validate([
'name' => 'required|max:30',
]);
$user = $request->user();
$token = $user->createToken($request->name, ['user:login'])->plainTextToken;
return back()->with('token', $token);
}
public function invokeAllApiToken(Request $request)
{
$user = $request->user();
$user->tokens()->delete();
return back()->with('success', 'OK');
}
public function logout()
{
Auth::logout();
// session()->destroy();
return redirect()->route('index');
}
}

View File

@ -3,12 +3,9 @@
namespace App\Http\Controllers;
use App\Helpers\ApiResponse;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ApiResponse;
use ApiResponse;
}

View File

@ -30,7 +30,7 @@ public function index()
public function store(Request $request)
{
// 存储计费项目
$request->validate([
$this->validate($request, [
'status' => 'required|in:running,stopped,error,suspended,pending',
'price' => 'required|numeric',
'user_id' => 'required|integer|exists:users,id',
@ -80,7 +80,7 @@ public function show(Host $host)
public function update(Request $request, Host $host)
{
//
$request->validate([
$this->validate($request, [
'status' => 'sometimes|in:running,stopped,error,suspended,pending',
// 'managed_price' => 'sometimes|numeric|nullable',

View File

@ -37,7 +37,7 @@ public function index(Request $request)
public function store(Request $request)
{
//
$request->validate([
$this->validate($request, [
'title' => 'required|max:255',
'progress' => 'sometimes|integer|max:100',
'status' => 'required|in:pending,processing,need_operation,done,success,failed,error,canceled',
@ -58,7 +58,7 @@ public function store(Request $request)
public function update(Request $request, Task $task)
{
//
$request->validate([
$this->validate($request, [
'progress' => 'sometimes|integer|max:100',
'status' => 'sometimes|in:pending,processing,need_operation,done,success,failed,error,canceled',
]);

View File

@ -17,7 +17,7 @@ public function index()
public function call(Request $request, Module $module)
{
$request->validate([
$this->validate($request, [
'func' => 'required|string'
]);
@ -39,7 +39,7 @@ public function call(Request $request, Module $module)
// 如果 method 为 post, 检查用户余额
if ($method == 'post') {
$user = auth('sanctum')->user();
$user = auth('api')->user();
if ($user->balance < 1) {
return $this->error('余额小于 1, 无法使用 POST 请求。');

View File

@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use App\Models\WorkOrder\Reply;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Log;
class ReplyController extends Controller
{
@ -29,22 +30,12 @@ public function index(Request $request)
public function store(Request $request)
{
//
// $request->validate([
// 'content' => 'string|required|min:1|max:1000',
// ]);
$request_array = $request->all();
// dd([
// 'content' => $request_array['content'],
// 'work_order_id' => $request->route('work_order'),
// ]);
$reply = Reply::create([
'content' => $request_array['content'],
'work_order_id' => $request->route('work_order'),
'work_order_id' => $request_array['work_order_id'],
]);
return $this->success($reply);

View File

@ -20,7 +20,7 @@ public function index(Request $request, WorkOrder $workOrder) {
// $work_orders = $work_orders->simplePaginate(10);
$workOrder = $workOrder->thisModule()->simplePaginate(10);
return $this->success($workOrder);
}
@ -34,7 +34,7 @@ public function show(WorkOrderRequest $request, WorkOrder $workOrder) {
public function update(WorkOrderRequest $request, WorkOrder $workOrder)
{
$request->validate([
$this->validate($request, [
'status' => 'nullable|sometimes|string|in:open,closed,on_hold,in_progress',
]);

View File

@ -23,7 +23,7 @@ public function index(Request $request)
public function store(Request $request)
{
// 充值
$request->validate([
$this->validate($request, [
'amount' => 'required|integer|min:1|max:10000',
]);
@ -38,19 +38,19 @@ public function store(Request $request)
'payment' => 'alipay',
];
// if local
if (env('APP_ENV') == 'local') {
$data['payment'] = null;
$data['paid_at'] = now();
}
// // if local
// if (env('APP_ENV') == 'local') {
// $data['payment'] = null;
// $data['paid_at'] = now();
// }
$balance = $balance->create($data);
if (env('APP_ENV') == 'local') {
$user->increment('balance', $request->amount);
return $this->success($balance);
}
// if (env('APP_ENV') == 'local') {
// $user->increment('balance', $request->amount);
// return $this->success($balance);
// }
@ -163,7 +163,7 @@ public function checkAndCharge($out_trade_no, Balance $balance)
// // 转换为 drops
// public function transfer($amount = 1)
// {
// $balance = auth('sanctum')->user();
// $balance = auth('api')->user();
// $balance->decrement('amount', $request->amount);
// return $this->success($balance);
// }

View File

@ -28,7 +28,7 @@ public function index(Drop $drop)
public function store(Request $request)
{
//
$request->validate([
$this->validate($request, [
'payment' => 'required',
'amount' => 'integer|required|min:1|max:1000',
]);

View File

@ -61,7 +61,7 @@ public function destroy(Host $host)
// public function store(Request $request, Module $module)
// {
// // User create host
// $request->validate([
// $this->validate($request, [
// 'name' => 'required|max:255',
// 'configuration' => 'required|json',
// ]);

View File

@ -32,15 +32,18 @@ public function index(WorkOrderRequest $request)
public function store(WorkOrderRequest $request)
{
// add reply
$request->validate([
$this->validate($request, [
'content' => 'string|required|min:1|max:1000',
]);
$reply = Reply::create([
'content' => $request->toArray()['content'],
'work_order_id' => $request->route('work_order'),
'work_order_id' => $request->route('workOrder')->id,
]);

View File

@ -13,12 +13,12 @@ class WorkOrderController extends Controller
public function index(Request $request, WorkOrder $workOrder) {
$workOrder = $workOrder->thisUser()->with('user')->simplePaginate(10);
return $this->success($workOrder);
}
public function store(Request $request) {
$request->validate([
$this->validate($request, [
'title' => 'required|max:255',
'content' => 'required',
'module_id' => 'nullable|sometimes|string|exists:modules,id',
@ -48,7 +48,7 @@ public function show(WorkOrderRequest $request, WorkOrder $workOrder) {
}
public function update(WorkOrderRequest $request, WorkOrder $workOrder) {
$request->validate([
$this->validate($request, [
'status' => 'nullable|sometimes|string|in:closed',
]);

View File

@ -2,8 +2,8 @@
namespace App\Http\Controllers;
use Cache;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class UserController extends Controller
{

View File

@ -1,77 +0,0 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'admin' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\AllowCors::class,
],
'remote' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\AllowCors::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}

View File

@ -3,7 +3,6 @@
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class AllowCors
{
@ -11,16 +10,35 @@ class AllowCors
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
public function handle($request, Closure $next)
{
$headers = [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, PATCH, DELETE',
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
];
// Allow from any origin
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
if ($request->isMethod('OPTIONS')) {
return response()->json('{"method":"OPTIONS"}', 200, $headers);
}
return $next($request);
$response = $next($request);
foreach ($headers as $key => $value) {
$response->header($key, $value);
}
return $response;
// // Pre-Middleware Action
// $response = $next($request);
// // Post-Middleware Action
// return $response;
}
}

View File

@ -2,20 +2,45 @@
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Closure;
use App\Helpers\ApiResponse;
use Illuminate\Contracts\Auth\Factory as Auth;
class Authenticate extends Middleware
class Authenticate
{
use ApiResponse;
/**
* Get the path the user should be redirected to when they are not authenticated.
* The authentication guard factory instance.
*
* @var \Illuminate\Contracts\Auth\Factory
*/
protected $auth;
/**
* Create a new middleware instance.
*
* @param \Illuminate\Contracts\Auth\Factory $auth
* @return void
*/
public function __construct(Auth $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @return string|null
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
protected function redirectTo($request)
public function handle($request, Closure $next, $guard = null)
{
if (! $request->expectsJson()) {
return route('login');
if ($this->auth->guard($guard)->guest()) {
return $this->forbidden('Unauthorized.');
}
return $next($request);
}
}

View File

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View File

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View File

@ -1,32 +0,0 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View File

@ -1,19 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

View File

@ -1,20 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

View File

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View File

@ -1,17 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Http\Request;
class BaseRequest extends Request
{
public function expectsJson()
{
return true;
}
public function wantsJson()
{
return true;
}
}

View File

@ -3,7 +3,7 @@
namespace App\Http\Requests\Remote\Server;
use App\Models\Server\Status;
use Illuminate\Foundation\Http\FormRequest;
use Anik\Form\FormRequest;
class StatusRequest extends FormRequest
{
@ -12,7 +12,7 @@ class StatusRequest extends FormRequest
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
$server = $this->route('server');
@ -24,7 +24,7 @@ public function authorize()
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
//

View File

@ -3,7 +3,7 @@
namespace App\Http\Requests\Remote;
use App\Models\WorkOrder\WorkOrder;
use Illuminate\Foundation\Http\FormRequest;
use Anik\Form\FormRequest;
class WorkOrderRequest extends FormRequest
{
@ -12,9 +12,18 @@ class WorkOrderRequest extends FormRequest
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return WorkOrder::where('id', $this->route('work_order')->id)->where('module_id', auth('remote')->id())->exists();
$work_order = $this->route('workOrder');
// if work_order is model
if ($work_order instanceof WorkOrder) {
$work_order_id = $work_order->id;
} else {
$work_order_id = $work_order;
}
return WorkOrder::where('id', $work_order_id)->where('module_id', auth('remote')->id())->exists();
}
/**
@ -22,7 +31,7 @@ public function authorize()
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
//

View File

@ -3,7 +3,7 @@
namespace App\Http\Requests\User\WorkOrder;
use App\Models\WorkOrder\WorkOrder;
use Illuminate\Foundation\Http\FormRequest;
use Anik\Form\FormRequest;
class WorkOrderRequest extends FormRequest
{
@ -12,10 +12,10 @@ class WorkOrderRequest extends FormRequest
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
$work_order = $this->route('work_order');
$work_order = $this->route('workOrder');
// if work_order is model
if ($work_order instanceof WorkOrder) {
@ -25,7 +25,7 @@ public function authorize()
}
return WorkOrder::where('user_id', auth('sanctum')->id())->where('id', $work_order_id)->exists();
return WorkOrder::where('user_id', auth('api')->id())->where('id', $work_order_id)->exists();
return false;
}
@ -35,7 +35,7 @@ public function authorize()
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
//

View File

@ -4,15 +4,15 @@
use App\Models\User\Task;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ClearTasks implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.

View File

@ -7,12 +7,12 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
class DeleteHost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.

26
app/Jobs/ExampleJob.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Jobs;
class ExampleJob extends Job
{
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
}
}

View File

@ -7,14 +7,14 @@
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;
class HostCost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Lock;
use InteractsWithQueue, Queueable, SerializesModels, Lock;
public $cache_key, $cache, $user;

24
app/Jobs/Job.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
abstract class Job implements ShouldQueue
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use InteractsWithQueue, Queueable, SerializesModels;
}

View File

@ -11,12 +11,12 @@
use Illuminate\Queue\InteractsWithQueue;
use GuzzleHttp\Exception\ConnectException;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
class FetchModule implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.

View File

@ -7,13 +7,13 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
use App\Models\Host as HostModel;
class Host implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
public HostModel $host;
public string $type;

View File

@ -8,12 +8,12 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
class PushHost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
@ -37,9 +37,9 @@ public function handle()
foreach ($hosts as $host) {
$http = Http::remote($host->module->api_token, $host->module->url);
$host->status = 'running';
$response = $http->post('hosts', $host->toArray());
if (!$response->successful()) {
$host->status = 'error';
}
@ -53,9 +53,9 @@ public function handle()
} else {
$host->status = 'error';
}
$host->save();
}
});
}

View File

@ -9,12 +9,13 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Support\Facades\Log;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
class PushWorkOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
@ -33,7 +34,7 @@ public function __construct()
*/
public function handle()
{
//
//
WorkOrder::whereIn('status', ['pending', 'error'])->with(['module', 'user', 'host', 'replies'])->chunk(100, function ($workOrders) {
foreach ($workOrders as $workOrder) {
@ -47,11 +48,15 @@ public function handle()
$response = $http->post('work-orders', $workOrder->toArray());
if (!$response->successful()) {
Log::error('推送工单失败', [
'work_order_id' => $workOrder->id,
'response' => $response->body(),
]);
$workOrder->status = 'error';
}
$workOrder->save();
}
});

View File

@ -7,14 +7,14 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
use App\Models\WorkOrder\Reply as WorkOrderReply;
use Log;
class Reply implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
protected $reply;
/**
@ -38,7 +38,7 @@ public function handle()
//
$this->reply->load(['workOrder', 'user']);
$this->reply->workOrder->load(['module']);
$http = Http::remote($this->reply->workOrder->module->api_token, $this->reply->workOrder->module->url);
$reply = $this->reply->toArray();

View File

@ -7,13 +7,12 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
// use Illuminate\Contracts\Queue\ShouldBeUnique;
use App\Models\WorkOrder\WorkOrder as WorkOrderWorkOrder;
class WorkOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use InteractsWithQueue, Queueable, SerializesModels;
protected $workOrder, $type;

View File

@ -0,0 +1,31 @@
<?php
namespace App\Listeners;
use App\Events\ExampleEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class ExampleListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param \App\Events\ExampleEvent $event
* @return void
*/
public function handle(ExampleEvent $event)
{
//
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class AccessToken extends Model
{
//
public function user() {
return $this->belongsTo(User::class);
}
}

View File

@ -143,8 +143,8 @@ protected static function boot()
// static::creating(function ($model) {
// // if sanctum
// // if (auth('sanctum')->check()) {
// // $model->user_id = auth('sanctum')->id();
// // if (auth('api')->check()) {
// // $model->user_id = auth('api')->id();
// // } else {
// // // if user_id is null
// // // check user_id is exists

View File

@ -2,15 +2,18 @@
namespace App\Models\Module;
use Http;
use Illuminate\Support\Str;
use Illuminate\Auth\Authenticatable;
use Illuminate\Support\Facades\Http;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
class Module extends Authenticatable
class Module extends Model implements AuthenticatableContract, AuthorizableContract
{
use HasFactory;
use Authenticatable, Authorizable, HasFactory;
protected $table = 'modules';
@ -59,9 +62,9 @@ public function remoteRequest($method, $func, $requests)
unset($requests['func']);
$requests['user_id'] = auth('sanctum')->id();
$requests['user_id'] = auth('api')->id();
$user = auth('sanctum')->user();
$user = auth('api')->user();
if ($method == 'post') {
// add user to requests

View File

@ -2,24 +2,25 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Laravel\Sanctum\HasApiTokens;
use App\Exceptions\CommonException;
use App\Exceptions\User\BalanceNotEnoughException;
use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Support\Facades\Cache;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use App\Exceptions\User\BalanceNotEnoughException;
use Illuminate\Contracts\Cache\LockTimeoutException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
class User extends Authenticatable
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use HasApiTokens, HasFactory, Notifiable;
use Authenticatable, Authorizable, HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var string[]
*/
protected $fillable = [
'name',
@ -29,20 +30,14 @@ class User extends Authenticatable
];
/**
* The attributes that should be hidden for serialization.
* The attributes excluded from the model's JSON form.
*
* @var array<int, string>
* @var string[]
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'balance' => 'float',
@ -87,4 +82,7 @@ public function toDrops($amount = 1)
return $this;
}
}

View File

@ -22,7 +22,7 @@ class Reply extends Model
public function workOrder()
{
return $this->belongsTo(WorkOrder::class);
return $this->belongsTo(WorkOrder::class, 'work_order_id', 'id');
}
public function user()
@ -48,10 +48,11 @@ protected static function boot()
// load work order
$model->load(['workOrder']);
throw_if($model->workOrder->status == 'pending' || $model->workOrder->status == 'error', CommonException::class, '工单状态不正确');
// change work order status
if (auth('sanctum')->check()) {
if (auth('api')->check()) {
$model->user_id = auth()->id();
$model->workOrder->status = 'user_replied';
}

View File

@ -71,8 +71,8 @@ protected static function boot()
}
// if logged
if (auth('sanctum')->check()) {
$model->user_id = auth('sanctum')->id();
if (auth('api')->check()) {
$model->user_id = auth('api')->id();
if ($model->host_id) {
if (!$model->user_id === $model->host->user_id) {

View File

@ -1,49 +0,0 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class CommonNotification extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toDatabase($notifiable)
{
return [
// title
// 'title' => $this->,
];
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace App\Policies\User;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class Drop
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
// show
public function show(User $user, Drop $drop)
{
// if not admin guard and not the same user
if (!$user->isAdmin() && $user->is($drop)) {
return false;
}
return true;
}
}

View File

@ -2,11 +2,11 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Alipay\EasySDK\Kernel\Config as AlipayConfig;
use Alipay\EasySDK\Kernel\Factory as AlipayFactory;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@ -18,17 +18,20 @@ class AppServiceProvider extends ServiceProvider
public function register()
{
//
require_once app()->basePath('app') . '/Helpers.php';
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
header('server: Cluster Ready!');
header('x-powered-by: LaeCloud');
header('x-for-you: Code is Poetry.');
Http::macro('remote', function ($api_token, $url) {
// 关闭证书验证
return Http::withoutVerifying()->withHeaders([

View File

@ -2,29 +2,68 @@
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use App\Models\AccessToken;
use App\Models\Module\Module;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
* Register any application services.
*
* @var array<class-string, class-string>
* @return void
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
public function register()
{
//
}
/**
* Register any authentication / authorization services.
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
//
// api guard and remote
$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return AccessToken::where('token', $request->input('api_token'))->with('user')->first()->user ?? null;
}
// bearerToken
$bearerToken = $request->bearerToken();
return AccessToken::where('token', $bearerToken)->with('user')->first()->user ?? null;
// if ($request->input('api_token')) {
// return User::where('api_token', $request->input('api_token'))->first();
// }
});
$this->app['auth']->viaRequest('remote', function ($request) {
if ($request->input('api_token')) {
return Module::where('api_token', $request->input('api_token'))->first();
}
// bearerToken
$bearerToken = $request->bearerToken();
return Module::where('token', $bearerToken)->first() ?? null;
// if ($request->input('api_token')) {
// return User::where('api_token', $request->input('api_token'))->first();
// }
});
}
}

View File

@ -1,21 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@ -2,34 +2,21 @@
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
* The event listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
\App\Events\ExampleEvent::class => [
\App\Listeners\ExampleListener::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*

View File

@ -0,0 +1,37 @@
<?php
namespace App\Providers;
use mmghv\LumenRouteBinding\RouteBindingServiceProvider as BaseServiceProvider;
class RouteBindingServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider
*/
public function boot()
{
// The binder instance
$binder = $this->binder;
$binder->implicitBind('App\Models');
$binder->implicitBind('App\Models\Module');
$binder->implicitBind('App\Models\Admin');
$binder->implicitBind('App\Models\Server');
$binder->implicitBind('App\Models\User');
$binder->implicitBind('App\Models\WorkOrder');
// Here we define our bindings
// $binder->bind('user', 'App\Models\User');
// $binder->bind(
// 'module',
// 'App\Models\Module\Module'
// );
// $binder->bind(
// 'workOrder',
// 'App\Models\WorkOrder\WorkOrder'
// );
// $binder->bind('reply', 'App\Models\WorkOrder\Reply');
// $binder->bind('task', 'App\Models\');
}
}

View File

@ -1,60 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('auth:admin')
->prefix('admin')
->group(base_path('routes/admin.php'));
Route::middleware('auth:remote')
->prefix('remote')
->group(base_path('routes/remote.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}

38
artisan
View File

@ -1,23 +1,21 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
| Create The Application
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app = require __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
@ -30,24 +28,8 @@ $app = require_once __DIR__.'/bootstrap/app.php';
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
$kernel = $app->make(
'Illuminate\Contracts\Console\Kernel'
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
exit($kernel->handle(new ArgvInput, new ConsoleOutput));

26
bin/fswatch Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
WORK_DIR=$1
if [ ! -n "${WORK_DIR}" ] ;then
WORK_DIR="."
fi
echo "Restarting LaravelS..."
./bin/laravels restart -d -i
echo "Starting fswatch..."
LOCKING=0
fswatch -e ".*" -i "\\.php$" -r ${WORK_DIR} | while read file
do
if [[ ! ${file} =~ .php$ ]] ;then
continue
fi
if [ ${LOCKING} -eq 1 ] ;then
echo "Reloading, skipped."
continue
fi
echo "File ${file} has been modified."
LOCKING=1
./bin/laravels reload
LOCKING=0
done
exit 0

28
bin/inotify Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
WORK_DIR=$1
if [ ! -n "${WORK_DIR}" ] ;then
WORK_DIR="."
fi
echo "Restarting LaravelS..."
./bin/laravels restart -d -i
echo "Starting inotifywait..."
LOCKING=0
inotifywait --event modify --event create --event move --event delete -mrq ${WORK_DIR} | while read file
do
if [[ ! ${file} =~ .php$ ]] ;then
continue
fi
if [ ${LOCKING} -eq 1 ] ;then
echo "Reloading, skipped."
continue
fi
echo "File ${file} has been modified."
LOCKING=1
./bin/laravels reload
LOCKING=0
done
exit 0

168
bin/laravels Executable file
View File

@ -0,0 +1,168 @@
#!/usr/bin/env php
<?php
/**
* This autoloader is only used to pull laravel-s.
* Class Psr4Autoloader
*/
class Psr4Autoloader
{
/**
* An associative array where the key is a namespace prefix and the value
* is an array of base directories for classes in that namespace.
*
* @var array
*/
protected $prefixes = [];
/**
* Register loader with SPL autoloader stack.
*
* @return void
*/
public function register()
{
spl_autoload_register([$this, 'loadClass']);
}
/**
* Adds a base directory for a namespace prefix.
*
* @param string $prefix The namespace prefix.
* @param string $base_dir A base directory for class files in the
* namespace.
* @param bool $prepend If true, prepend the base directory to the stack
* instead of appending it; this causes it to be searched first rather
* than last.
* @return void
*/
public function addNamespace($prefix, $base_dir, $prepend = false)
{
// normalize namespace prefix
$prefix = trim($prefix, '\\') . '\\';
// normalize the base directory with a trailing separator
$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';
// initialize the namespace prefix array
if (isset($this->prefixes[$prefix]) === false) {
$this->prefixes[$prefix] = [];
}
// retain the base directory for the namespace prefix
if ($prepend) {
array_unshift($this->prefixes[$prefix], $base_dir);
} else {
$this->prefixes[$prefix][] = $base_dir;
}
}
/**
* Loads the class file for a given class name.
*
* @param string $class The fully-qualified class name.
* @return mixed The mapped file name on success, or boolean false on
* failure.
*/
public function loadClass($class)
{
// the current namespace prefix
$prefix = $class;
// work backwards through the namespace names of the fully-qualified
// class name to find a mapped file name
while (false !== $pos = strrpos($prefix, '\\')) {
// retain the trailing namespace separator in the prefix
$prefix = substr($class, 0, $pos + 1);
// the rest is the relative class name
$relative_class = substr($class, $pos + 1);
// try to load a mapped file for the prefix and relative class
$mapped_file = $this->loadMappedFile($prefix, $relative_class);
if ($mapped_file) {
return $mapped_file;
}
// remove the trailing namespace separator for the next iteration
// of strrpos()
$prefix = rtrim($prefix, '\\');
}
// never found a mapped file
return false;
}
/**
* Load the mapped file for a namespace prefix and relative class.
*
* @param string $prefix The namespace prefix.
* @param string $relative_class The relative class name.
* @return mixed Boolean false if no mapped file can be loaded, or the
* name of the mapped file that was loaded.
*/
protected function loadMappedFile($prefix, $relative_class)
{
// are there any base directories for this namespace prefix?
if (isset($this->prefixes[$prefix]) === false) {
return false;
}
// look through base directories for this namespace prefix
foreach ($this->prefixes[$prefix] as $base_dir) {
// replace the namespace prefix with the base directory,
// replace namespace separators with directory separators
// in the relative class name, append with .php
$file = $base_dir
. str_replace('\\', '/', $relative_class)
. '.php';
// if the mapped file exists, require it
if ($this->requireFile($file)) {
// yes, we're done
return $file;
}
}
// never found it
return false;
}
/**
* If a file exists, require it from the file system.
*
* @param string $file The file to require.
* @return bool True if the file exists, false if not.
*/
public function requireFile($file)
{
if (file_exists($file)) {
require $file;
return true;
}
return false;
}
}
$basePath = dirname(__DIR__) . '/';
$loader = new Psr4Autoloader();
$loader->register();
// Register laravel-s
$loader->addNamespace('Hhxsv5\LaravelS', $basePath . '/vendor/hhxsv5/laravel-s/src');
// Register laravel-s dependencies
// To fix issue #364 https://github.com/hhxsv5/laravel-s/issues/364
$loader->addNamespace('Symfony\Polyfill\Php80', $basePath . '/vendor/symfony/polyfill-php80');
$loader->requireFile($basePath . '/vendor/symfony/polyfill-php80/bootstrap.php');
$loader->addNamespace('Symfony\Component\Console', $basePath . '/vendor/symfony/console');
$loader->addNamespace('Symfony\Contracts\Service', $basePath . '/vendor/symfony/service-contracts');
$loader->addNamespace('Symfony\Contracts', $basePath . '/vendor/symfony/contracts');
$command = new Hhxsv5\LaravelS\Console\Portal($basePath);
$input = new Symfony\Component\Console\Input\ArgvInput();
$output = new Symfony\Component\Console\Output\ConsoleOutput();
$code = $command->run($input, $output);
exit($code);

View File

@ -1,34 +1,46 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
dirname(__DIR__)
))->bootstrap();
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
$app = new Laravel\Lumen\Application(
dirname(__DIR__)
);
$app->withFacades();
$app->withEloquent();
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
$app->singleton(
@ -36,20 +48,105 @@
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
| Register Config Files
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
| Now we will register the "app" configuration file. If the file exists in
| your configuration directory it will be loaded; otherwise, we'll load
| the default version. You may register other files below as needed.
|
*/
$app->configure('app');
$app->configure('auth');
$app->configure('cache');
$app->configure('database');
$app->configure('laravels');
$app->configure('oauth');
$app->configure('queue');
$app->configure('session');
$app->configure('alipay');
/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
$app->middleware([
// App\Http\Middleware\ExampleMiddleware::class
\App\Http\Middleware\AllowCors::class,
]);
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
// 'remote' => [
// \Illuminate\Routing\Middleware\SubstituteBindings::class,
// \App\Http\Middleware\AllowCors::class,
// ],
'cors' => \App\Http\Middleware\AllowCors::class,
]);
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/
$app->register(App\Providers\AppServiceProvider::class);
$app->register(App\Providers\AuthServiceProvider::class);
$app->register(Illuminate\Redis\RedisServiceProvider::class);
$app->register(Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class);
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(\Anik\Form\FormRequestServiceProvider::class);
$app->register(App\Providers\RouteBindingServiceProvider::class);
/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__ . '/../routes/web.php';
});
$app->router->group([
'namespace' => 'App\Http\Controllers',
'prefix' => 'api',
'middleware' => ['auth:api'],
], function ($router) {
require __DIR__ . '/../routes/api.php';
});
$app->router->group([
'namespace' => 'App\Http\Controllers\Remote',
'prefix' => 'remote',
'middleware' => ['auth:remote'],
], function ($router) {
require __DIR__ . '/../routes/remote.php';
});
return $app;

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,34 +1,31 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": [
"framework",
"laravel"
"laravel",
"lumen"
],
"license": "MIT",
"type": "project",
"require": {
"php": "^8.0.2",
"php": "^8.0",
"alipaysdk/easysdk": "^2.0",
"anik/form-request": "^4.5",
"doctrine/dbal": "^3.3",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/octane": "^1.2",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"league/omnipay": "^3",
"spiral/roadrunner": "^2.8.2"
"flipbox/lumen-generator": "^9.1",
"guzzlehttp/guzzle": "^7.5",
"hhxsv5/laravel-s": "~3.7.0",
"illuminate/redis": "^9.28",
"laravel/lumen-framework": "^9.0",
"league/flysystem": "^3.2",
"mmghv/lumen-route-binding": "^1.0",
"predis/predis": "^2.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0",
"laravel/horizon": "^5.9",
"laravel/telescope": "^4.9"
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
@ -43,25 +40,10 @@
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",

6134
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,5 @@
<?php
use Illuminate\Support\Facades\Facade;
return [
/*
@ -15,7 +13,7 @@
|
*/
'name' => env('APP_NAME', 'Laravel'),
'name' => env('APP_NAME', 'LAEv3'),
/*
|--------------------------------------------------------------------------
@ -56,8 +54,6 @@
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------
| Application Timezone
@ -82,7 +78,7 @@
|
*/
'locale' => 'en',
'locale' => env('APP_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
@ -95,20 +91,7 @@
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
@ -125,91 +108,4 @@
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
])->toArray(),
];

View File

@ -14,8 +14,8 @@
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
// 'guard' => env('AUTH_GUARD', 'api'),
'guard' => 'api',
],
/*
@ -31,24 +31,28 @@
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
| Supported: "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
// 'web' => [
// 'driver' => 'session',
// 'provider' => 'users',
// ],
'admin' => [
'driver' => 'token',
'provider' => 'admins',
],
// 'admin' => [
// 'driver' => 'token',
// 'provider' => 'admins',
// ],
'remote' => [
'driver' => 'token',
'provider' => 'providers',
'provider' => 'modules',
],
'api' => [
'driver' => 'api'
],
],
@ -70,6 +74,8 @@
*/
'providers' => [
//
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
@ -80,15 +86,10 @@
'model' => App\Models\Admin\Admin::class,
],
'providers' => [
'modules' => [
'driver' => 'eloquent',
'model' => App\Models\Module\Module::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
@ -96,36 +97,22 @@
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
//
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];

View File

@ -1,70 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

View File

@ -13,9 +13,11 @@
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
'default' => 'redis',
/*
|--------------------------------------------------------------------------
@ -26,72 +28,13 @@
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
'connection' => env('CACHE_REDIS_CONNECTION', 'cache'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
@ -99,12 +42,15 @@
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
| stores there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', 'laev3_cache'),
'prefix' => env(
'CACHE_PREFIX',
'laev3_cache'
),
];

View File

@ -1,34 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

View File

@ -34,65 +34,37 @@
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'strict' => env('DB_STRICT_MODE', true),
'engine' => env('DB_ENGINE'),
'timezone' => env('DB_TIMEZONE', '+00:00'),
'options' => [
PDO::ATTR_PERSISTENT => true,
],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'port' => env('DB_PORT', 5432),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
'search_path' => env('DB_SCHEMA', 'public'),
'sslmode' => env('DB_SSL_MODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
@ -114,7 +86,7 @@
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
@ -125,13 +97,12 @@
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'lumen'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
@ -140,7 +111,6 @@
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),

View File

@ -1,76 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

View File

@ -1,52 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];

308
config/laravels.php Normal file
View File

@ -0,0 +1,308 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| LaravelS Settings
|--------------------------------------------------------------------------
|
| English https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#laravels-settings
| Chinese https://github.com/hhxsv5/laravel-s/blob/master/Settings-CN.md#laravels-%E9%85%8D%E7%BD%AE%E9%A1%B9
|
*/
/*
|--------------------------------------------------------------------------
| The IP address of the server
|--------------------------------------------------------------------------
|
| IPv4: use "127.0.0.1" to listen local address, and "0.0.0.0" to listen all addresses.
| IPv6: use "::1" to listen local address, and "::"(equivalent to 0:0:0:0:0:0:0:0) to listen all addresses.
|
*/
'listen_ip' => env('LARAVELS_LISTEN_IP', '127.0.0.1'),
/*
|--------------------------------------------------------------------------
| The port of the server
|--------------------------------------------------------------------------
|
| Require root privilege if port is less than 1024.
|
*/
'listen_port' => env('LARAVELS_LISTEN_PORT', 5200),
/*
|--------------------------------------------------------------------------
| The socket type of the server
|--------------------------------------------------------------------------
|
| Usually, you dont need to care about it.
| Unless you want Nginx to proxy to the UnixSocket Stream file, you need
| to modify it to SWOOLE_SOCK_UNIX_STREAM, and listen_ip is the path of UnixSocket Stream file.
| List of socket types:
| SWOOLE_SOCK_TCP: TCP
| SWOOLE_SOCK_TCP6: TCP IPv6
| SWOOLE_SOCK_UDP: UDP
| SWOOLE_SOCK_UDP6: UDP IPv6
| SWOOLE_UNIX_DGRAM: Unix socket dgram
| SWOOLE_UNIX_STREAM: Unix socket stream
| Enable SSL: $sock_type | SWOOLE_SSL. To enable SSL, check the configuration about SSL.
| https://www.swoole.co.uk/docs/modules/swoole-server-doc
| https://www.swoole.co.uk/docs/modules/swoole-server/configuration
|
*/
'socket_type' => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : 1,
/*
|--------------------------------------------------------------------------
| Server Name
|--------------------------------------------------------------------------
|
| This value represents the name of the server that will be
| displayed in the header of each request.
|
*/
'server' => env('LARAVELS_SERVER', 'LaravelS'),
/*
|--------------------------------------------------------------------------
| Handle Static Resource
|--------------------------------------------------------------------------
|
| Whether handle the static resource by LaravelS(Require Swoole >= 1.7.21, Handle by Swoole if Swoole >= 1.9.17).
| Suggest that Nginx handles the statics and LaravelS handles the dynamics.
| The default path of static resource is base_path('public'), you can modify swoole.document_root to change it.
|
*/
'handle_static' => env('LARAVELS_HANDLE_STATIC', false),
/*
|--------------------------------------------------------------------------
| Laravel Base Path
|--------------------------------------------------------------------------
|
| The basic path of Laravel, default base_path(), be used for symbolic link.
|
*/
'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()),
/*
|--------------------------------------------------------------------------
| Inotify Reload
|--------------------------------------------------------------------------
|
| This feature requires inotify extension.
| https://github.com/hhxsv5/laravel-s#automatically-reload-after-modifying-code
|
*/
'inotify_reload' => [
// Whether enable the Inotify Reload to reload all worker processes when your code is modified.
'enable' => env('LARAVELS_INOTIFY_RELOAD', false),
// The file path that Inotify watches
'watch_path' => base_path(),
// The file types that Inotify watches
'file_types' => ['.php'],
// The excluded/ignored directories that Inotify watches
'excluded_dirs' => [],
// Whether output the reload log
'log' => true,
],
/*
|--------------------------------------------------------------------------
| Swoole Event Handlers
|--------------------------------------------------------------------------
|
| Configure the event callback function of Swoole, key-value format,
| key is the event name, and value is the class that implements the event
| processing interface.
|
| https://github.com/hhxsv5/laravel-s#configuring-the-event-callback-function-of-swoole
|
*/
'event_handlers' => [],
/*
|--------------------------------------------------------------------------
| WebSockets
|--------------------------------------------------------------------------
|
| Swoole WebSocket Server settings.
|
| https://github.com/hhxsv5/laravel-s#enable-websocket-server
|
*/
'websocket' => [
'enable' => false,
// 'handler' => XxxWebSocketHandler::class,
],
/*
|--------------------------------------------------------------------------
| Sockets - multi-port mixed protocol
|--------------------------------------------------------------------------
|
| The socket(port) list for TCP/UDP.
|
| https://github.com/hhxsv5/laravel-s#multi-port-mixed-protocol
|
*/
'sockets' => [],
/*
|--------------------------------------------------------------------------
| Custom Process
|--------------------------------------------------------------------------
|
| Support developers to create custom processes for monitoring,
| reporting, or other special tasks.
|
| https://github.com/hhxsv5/laravel-s#custom-process
|
*/
'processes' => [],
/*
|--------------------------------------------------------------------------
| Timer
|--------------------------------------------------------------------------
|
| Wrapper cron job base on Swoole's Millisecond Timer, replace Linux Crontab.
|
| https://github.com/hhxsv5/laravel-s#millisecond-cron-job
|
*/
'timer' => [
'enable' => env('LARAVELS_TIMER', false),
// The list of cron job
'jobs' => [
// Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab
// Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class,
],
// Max waiting time of reloading
'max_wait_time' => 5,
// Enable the global lock to ensure that only one instance starts the timer
// when deploying multiple instances.
// This feature depends on Redis https://laravel.com/docs/8.x/redis
'global_lock' => false,
'global_lock_key' => config('app.name', 'Laravel'),
],
/*
|--------------------------------------------------------------------------
| Swoole Tables
|--------------------------------------------------------------------------
|
| All defined tables will be created before Swoole starting.
|
| https://github.com/hhxsv5/laravel-s#use-swooletable
|
*/
'swoole_tables' => [],
/*
|--------------------------------------------------------------------------
| Re-register Providers
|--------------------------------------------------------------------------
|
| The Service Provider list, will be re-registered each request, and run method boot()
| if it exists. Usually, be used to clear the Service Provider
| which registers Singleton instances.
|
| https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#register_providers
|
*/
'register_providers' => [],
/*
|--------------------------------------------------------------------------
| Cleaners
|--------------------------------------------------------------------------
|
| The list of cleaners for each request is used to clean up some residual
| global variables, singleton objects, and static properties to avoid
| data pollution between requests.
|
| https://github.com/hhxsv5/laravel-s/blob/master/Settings.md#cleaners
|
*/
'cleaners' => [],
/*
|--------------------------------------------------------------------------
| Destroy Controllers
|--------------------------------------------------------------------------
|
| Automatically destroy the controllers after each request to solve
| the problem of the singleton controllers.
|
| https://github.com/hhxsv5/laravel-s/blob/master/KnownIssues.md#singleton-controller
|
*/
'destroy_controllers' => [
'enable' => false,
'excluded_list' => [],
],
/*
|--------------------------------------------------------------------------
| Swoole Settings
|--------------------------------------------------------------------------
|
| Swoole's original configuration items.
|
| More settings
| Chinese https://wiki.swoole.com/#/server/setting
| English https://www.swoole.co.uk/docs/modules/swoole-server/configuration
|
*/
'swoole' => [
'daemonize' => env('LARAVELS_DAEMONIZE', false),
'dispatch_mode' => env('LARAVELS_DISPATCH_MODE', 3),
'worker_num' => env('LARAVELS_WORKER_NUM', 30),
//'task_worker_num' => env('LARAVELS_TASK_WORKER_NUM', 10),
'task_ipc_mode' => 1,
'task_max_request' => env('LARAVELS_TASK_MAX_REQUEST', 100000),
'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'max_request' => env('LARAVELS_MAX_REQUEST', 100000),
'open_tcp_nodelay' => true,
'pid_file' => storage_path('laravels.pid'),
'log_level' => env('LARAVELS_LOG_LEVEL', 4),
'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
'document_root' => base_path('public'),
'buffer_output_size' => 2 * 1024 * 1024,
'socket_buffer_size' => 8 * 1024 * 1024,
'package_max_length' => 4 * 1024 * 1024,
'reload_async' => true,
'max_wait_time' => 60,
'enable_reuse_port' => true,
'enable_coroutine' => false,
'upload_tmp_dir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'http_compression' => env('LARAVELS_HTTP_COMPRESSION', false),
],
];

View File

@ -1,122 +0,0 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false,
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

View File

@ -1,118 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

View File

@ -1,10 +0,0 @@
<?php
return [
'callback_uri' => env('OAUTH_REDIRECT'),
'client_id' => env('OAUTH_CLIENT_ID'),
'client_secret' => env('OAUTH_CLIENT_SECRET'),
'oauth_auth_url' => env('OAUTH_DOMAIN') . '/oauth/authorize',
'oauth_token_url' => env('OAUTH_DOMAIN') . '/oauth/token',
'oauth_user_url' => env('OAUTH_DOMAIN') . '/api/user',
];

View File

@ -1,221 +0,0 @@
<?php
use Laravel\Octane\Contracts\OperationTerminated;
use Laravel\Octane\Events\RequestHandled;
use Laravel\Octane\Events\RequestReceived;
use Laravel\Octane\Events\RequestTerminated;
use Laravel\Octane\Events\TaskReceived;
use Laravel\Octane\Events\TaskTerminated;
use Laravel\Octane\Events\TickReceived;
use Laravel\Octane\Events\TickTerminated;
use Laravel\Octane\Events\WorkerErrorOccurred;
use Laravel\Octane\Events\WorkerStarting;
use Laravel\Octane\Events\WorkerStopping;
use Laravel\Octane\Listeners\CollectGarbage;
use Laravel\Octane\Listeners\DisconnectFromDatabases;
use Laravel\Octane\Listeners\EnsureUploadedFilesAreValid;
use Laravel\Octane\Listeners\EnsureUploadedFilesCanBeMoved;
use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
use Laravel\Octane\Listeners\FlushUploadedFiles;
use Laravel\Octane\Listeners\ReportException;
use Laravel\Octane\Listeners\StopWorkerIfNecessary;
use Laravel\Octane\Octane;
return [
/*
|--------------------------------------------------------------------------
| Octane Server
|--------------------------------------------------------------------------
|
| This value determines the default "server" that will be used by Octane
| when starting, restarting, or stopping your server via the CLI. You
| are free to change this to the supported server of your choosing.
|
| Supported: "roadrunner", "swoole"
|
*/
'server' => env('OCTANE_SERVER', 'roadrunner'),
/*
|--------------------------------------------------------------------------
| Force HTTPS
|--------------------------------------------------------------------------
|
| When this configuration value is set to "true", Octane will inform the
| framework that all absolute links must be generated using the HTTPS
| protocol. Otherwise your links may be generated using plain HTTP.
|
*/
'https' => env('OCTANE_HTTPS', false),
/*
|--------------------------------------------------------------------------
| Octane Listeners
|--------------------------------------------------------------------------
|
| All of the event listeners for Octane's events are defined below. These
| listeners are responsible for resetting your application's state for
| the next request. You may even add your own listeners to the list.
|
*/
'listeners' => [
WorkerStarting::class => [
EnsureUploadedFilesAreValid::class,
EnsureUploadedFilesCanBeMoved::class,
],
RequestReceived::class => [
...Octane::prepareApplicationForNextOperation(),
...Octane::prepareApplicationForNextRequest(),
//
],
RequestHandled::class => [
//
],
RequestTerminated::class => [
// FlushUploadedFiles::class,
],
TaskReceived::class => [
...Octane::prepareApplicationForNextOperation(),
//
],
TaskTerminated::class => [
//
],
TickReceived::class => [
...Octane::prepareApplicationForNextOperation(),
//
],
TickTerminated::class => [
//
],
OperationTerminated::class => [
FlushTemporaryContainerInstances::class,
// DisconnectFromDatabases::class,
// CollectGarbage::class,
],
WorkerErrorOccurred::class => [
ReportException::class,
StopWorkerIfNecessary::class,
],
WorkerStopping::class => [
//
],
],
/*
|--------------------------------------------------------------------------
| Warm / Flush Bindings
|--------------------------------------------------------------------------
|
| The bindings listed below will either be pre-warmed when a worker boots
| or they will be flushed before every new request. Flushing a binding
| will force the container to resolve that binding again when asked.
|
*/
'warm' => [
...Octane::defaultServicesToWarm(),
],
'flush' => [
//
],
/*
|--------------------------------------------------------------------------
| Octane Cache Table
|--------------------------------------------------------------------------
|
| While using Swoole, you may leverage the Octane cache, which is powered
| by a Swoole table. You may set the maximum number of rows as well as
| the number of bytes per row using the configuration options below.
|
*/
'cache' => [
'rows' => 1000,
'bytes' => 10000,
],
/*
|--------------------------------------------------------------------------
| Octane Swoole Tables
|--------------------------------------------------------------------------
|
| While using Swoole, you may define additional tables as required by the
| application. These tables can be used to store data that needs to be
| quickly accessed by other workers on the particular Swoole server.
|
*/
'tables' => [
'example:1000' => [
'name' => 'string:1000',
'votes' => 'int',
],
],
/*
|--------------------------------------------------------------------------
| File Watching
|--------------------------------------------------------------------------
|
| The following list of files and directories will be watched when using
| the --watch option offered by Octane. If any of the directories and
| files are changed, Octane will automatically reload your workers.
|
*/
'watch' => [
'app',
'bootstrap',
'config',
'database',
'public/**/*.php',
'resources/**/*.php',
'routes',
'composer.lock',
'.env',
],
/*
|--------------------------------------------------------------------------
| Garbage Collection Threshold
|--------------------------------------------------------------------------
|
| When executing long-lived PHP scripts such as Octane, memory can build
| up before being cleared by PHP. You can force Octane to run garbage
| collection if your application consumes this amount of megabytes.
|
*/
'garbage' => 50,
/*
|--------------------------------------------------------------------------
| Maximum Execution Time
|--------------------------------------------------------------------------
|
| The following setting configures the maximum execution time for requests
| being handled by Octane. You may set this value to 0 to indicate that
| there isn't a specific time limit on Octane request execution time.
|
*/
'max_execution_time' => 30,
];

View File

@ -7,13 +7,13 @@
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| Lumen's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
'default' => 'redis',
/*
|--------------------------------------------------------------------------
@ -22,7 +22,7 @@
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
| for each back-end shipped with Lumen. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
@ -36,10 +36,9 @@
'database' => [
'driver' => 'database',
'table' => 'jobs',
'table' => env('QUEUE_TABLE', 'jobs'),
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
@ -47,28 +46,23 @@
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'key' => env('SQS_KEY', 'your-public-key'),
'secret' => env('SQS_SECRET', 'your-secret-key'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('SQS_REGION', 'us-east-1'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'connection' => env('QUEUE_REDIS_CONNECTION', 'default'),
'queue' => 'default',
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
@ -87,7 +81,7 @@
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
'table' => env('QUEUE_FAILED_TABLE', 'failed_jobs'),
],
];

View File

@ -1,67 +0,0 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort()
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
],
];

View File

@ -1,34 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
'scheme' => 'https',
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
];

View File

@ -1,201 +0,0 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| While using one of the framework's cache driven session backends you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
];

View File

@ -1,36 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

1
database/.gitignore vendored
View File

@ -1 +0,0 @@
*.sqlite*

View File

@ -2,41 +2,28 @@
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
* @return array
*/
public function definition()
{
return [
'name' => fake()->name(),
'email' => fake()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
//
// drop column if exists
if (Schema::hasColumn('users', 'drops')) {
$table->dropColumn('drops');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('access_tokens', function (Blueprint $table) {
// string primary key
$table->string('token', 64)->primary()->unique();
$table->unsignedBigInteger('user_id')->index();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('access_tokens');
}
};

Some files were not shown because too many files have changed in this diff Show More