This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

48
.env.example Normal file
View File

@@ -0,0 +1,48 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
SERVER_ID=001
RATE_LIMITER=300
ADMIN_HTTPS=false
ADMIN_NAME="Uz.Tech 后台系统"
ADMIN_TITLE='Uz.Tech'
ADMIN_LOGO="<b>UZ</b> Tech"
ADMIN_LOGO_MINI="<b>U.T</b>"
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_DB=1
REDIS_CACHE_DB=1
FILESYSTEM_DRIVER=public
OSS_ACCESS_KEY=
OSS_SECRET_KEY=
OSS_ENDPOINT=
OSS_BUCKET=
OSS_IS_CNAME=false
OSS_CDN_HOST=

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

16
.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.idea
.DS_Store
.vscode/

13
.styleci.yml Normal file
View File

@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

123
README.md Normal file
View File

@@ -0,0 +1,123 @@
<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>
# UzTech.Laravel
> Jason.Chen , 为了构建一个健壮的底层。
[TOC]
## 1.安装
```shell
git pull http://git.yuzhankeji.cn/UzTech/laravel.git
```
```shell
# 生成 laravel 密钥
php artisan key:generate --ansi
# 数据库迁移
php artisan migrate
# 数据填充(初始化基础数据)
php artisan db:seed --class=AdminPanelSeeder
```
手动导入 initial.sql 后台数据基础文件
## 包含的基础组件
> OSS文件管理包
>
> "jasonc/laravel-filesystem-oss": "^3.0"
>
> 模块化工具
>
> "nwidart/laravel-modules": "^8.2"
>
> 模块安装工具
>
> "joshbrw/laravel-module-installer": "^2.0"
>
> API 管理工具
>
> "jasonc/api": "^3.3"
>
> 后台模板
>
> "encore/laravel-admin": "^1.8"
## 模块安装
> 模块安装完毕之后,要执行 composer dump-autoload
### 1.
## 模块开发
### 1. 创建新模块
```shell
php artisan module:make ModuleName
```
### 2. 模块目录的一些规范
```
modules/
├── Blog/
├── Config/ 配置目录,使用 Config::get('module_name.') 调用
├── Console/ 控制台命令
├── Kernel.php 执行定时任务
├── Database/ 数据库
├── Migrations/ 数据表单迁移
├── Seeders/ 数据填充文件
├── Events/ 事件目录
├── Http/
├── Controllers/ 控制器
├── Admin/
├── Api/
├── Middleware/ 中间件目录
├── Requests/ 请求验证
├── Resources API接口资源
├── Jobs/ 队列
├── Listeners/ 监听器
├── Models/ 模型
├── Traits/ 模块内部模型使用的traits
├── Providers/
├── BlogServiceProvider.php
├── RouteServiceProvider.php
├── Resources/ 静态资源目录
├── assets/
├── js/
├── app.js
├── sass/
├── app.scss
├── lang/
├── views/
├── Routes/ 路由
├── admin.php
├── api.php
├── Service/ 内部服务
├── Traits/ 对外的traits
├── composer.json
├── module.json
├── README.md
```
### 3. 定时任务相关说明
```php
// 定时任务命令在ServiceProvider中加载
if ($this->app->runningInConsole()) {
$this->commands([]);
}
// 定时任务的执行
// 在模型文件夹 Console 建立 Kernel 类,类中 runCommand 执行定时任务
$schedule->command(**)->everyMinute();
```
### 4. 查看全部路由,优化组件
```shell
php artisan route:pretty
```

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Admin\Controllers;
use Encore\Admin\Controllers\AuthController as BaseAuthController;
class AuthController extends BaseAuthController
{
}

View File

@@ -0,0 +1,183 @@
<?php
namespace App\Admin\Controllers;
use Encore\Admin\Admin;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Arr;
use Illuminate\View\View;
use Nwidart\Modules\Facades\Module;
class Dashboard
{
/**
* @return Factory|View
*/
public static function title()
{
return view('admin.dashboard.title');
}
/**
* @return Factory|View
*/
public static function environment()
{
$envs = [
['name' => 'PHP version', 'value' => 'PHP/'.PHP_VERSION],
['name' => 'Laravel version', 'value' => app()->version()],
['name' => 'CGI', 'value' => php_sapi_name()],
['name' => 'Uname', 'value' => php_uname()],
['name' => 'Server', 'value' => Arr::get($_SERVER, 'SERVER_SOFTWARE')],
['name' => 'Cache driver', 'value' => config('cache.default')],
['name' => 'Session driver', 'value' => config('session.driver')],
['name' => 'Queue driver', 'value' => config('queue.default')],
['name' => 'Timezone', 'value' => config('app.timezone')],
['name' => 'Locale', 'value' => config('app.locale')],
['name' => 'Env', 'value' => config('app.env')],
['name' => 'URL', 'value' => config('app.url')],
];
return view('admin.dashboard.environment', compact('envs'));
}
/**
* @return Factory|View
*/
public static function extensions()
{
$extensions = [
'user' => [
'name' => '用户模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-user-module',
'icon' => 'users',
],
'chain' => [
'name' => '区块链管理',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-chain-module',
'icon' => 'chain',
],
'lottery' => [
'name' => '抽奖模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-lottery-module',
'icon' => 'gavel',
],
'task' => [
'name' => '任务模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-task-module',
'icon' => 'hourglass-end',
],
'cms' => [
'name' => '内容管理',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-cms-module',
'icon' => 'book',
],
'appversion' => [
'name' => 'App版本',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-appversion-module',
'icon' => 'apple',
],
'mall' => [
'name' => '多用户商城',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-mall-module',
'icon' => 'shopping-cart',
],
'payment' => [
'name' => '支付模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-payment-module',
'icon' => 'paypal',
],
'company' => [
'name' => '企业管理',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-company-module',
'icon' => 'black-tie',
],
'coupon' => [
'name' => '优惠券模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-coupon-module',
'icon' => 'qrcode',
],
'settlement' => [
'name' => '结算模块',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-settlement-module',
'icon' => 'sliders',
],
'configuration' => [
'name' => '参数配置',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-configuration-module',
'icon' => 'cogs',
],
'withdraw' => [
'name' => '提现管理',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-withdraw-module',
'icon' => 'clock-o',
],
'notification' => [
'name' => '消息中心',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-notification-module',
'icon' => 'envelope',
],
'linker' => [
'name' => '链接管理',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-linker-module',
'icon' => 'link',
],
'storage' => [
'name' => '文件存储',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-storage-module',
'icon' => 'file',
],
'omniform' => [
'name' => '万能表单',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-omni-form-module',
'icon' => 'wpforms',
],
'tao' => [
'name' => '淘宝客',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-tao-module',
'icon' => 'simplybuilt',
],
'market' => [
'name' => '交易市场',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-market-module',
'icon' => 'asl-interpreting',
],
'tokenmall' => [
'name' => '区块链商城',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-token-mall-module',
'icon' => 'flask',
],
'acme' => [
'name' => 'SSL免费证书',
'link' => 'https://git.yuzhankeji.cn/UzTech/laravel-acme-module',
'icon' => 'html5',
],
];
foreach ($extensions as $key => &$extension) {
$module = Module::find($key);
if ($module) {
$extension['installed'] = (int) $module->isEnabled();
} else {
$extension['installed'] = 2;
}
}
return view('admin.dashboard.extensions', compact('extensions'));
}
/**
* @return string
*/
public static function dependencies(): string
{
$json = file_get_contents(base_path('composer.json'));
$dependencies = json_decode($json, true)['require'];
return Admin::component('admin.dashboard.dependencies', compact('dependencies'));
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Admin\Controllers;
use App\Http\Controllers\Controller;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
class HomeController extends Controller
{
/**
* Notes : 数据看板
*
* @Date : 2021/3/10 5:12 下午
* @Author : <Jason.C>
* @param Content $content
* @return Content
*/
public function index(Content $content): Content
{
if (config('app.debug')) {
return $content
->title(__('admin.menu_titles.dashboard'))
->description('Description...')
->row(Dashboard::title())
->row(function (Row $row) {
$row->column(4, function (Column $column) {
$column->append(Dashboard::environment());
});
$row->column(4, function (Column $column) {
$column->append(Dashboard::dependencies());
});
$row->column(4, function (Column $column) {
$column->append(Dashboard::extensions());
});
});
} else {
return $content
->title(__('admin.menu_titles.dashboard'))
->description('Description...');
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Admin\Controllers;
use App\Models\Module;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Grid;
use Illuminate\Http\RedirectResponse;
use Nwidart\Modules\Facades\Module as ModuleManager;
class ModuleController extends AdminController
{
protected $title = '模块管理';
/**
* Notes : 模块列表
*
* @Date : 2021/10/28 9:18 上午
* @Author : <Jason.C>
* @return Grid
*/
protected function grid(): Grid
{
$grid = new Grid(new Module());
$grid->disableBatchActions();
$grid->disableFilter();
$grid->disableCreateButton();
$grid->disableActions();
$grid->column('name', '模块名称');
$grid->column('alias', '别名');
$grid->column('version', '版本');
$grid->column('author', '作者');
$grid->column('description', '模块简介');
$grid->column('enabled', '状态')->bool();
$grid->column('id', '操作')->display(function () {
if ($this->enabled) {
return sprintf('<a href="%s">%s</a>', route('admin.module.disable', $this->name), '禁用');
} else {
return sprintf('<a href="%s">%s</a>', route('admin.module.enable', $this->name), '启用');
}
});
return $grid;
}
/**
* Notes : 禁用模块
*
* @Date : 2021/3/11 1:13 下午
* @Author : <Jason.C>
* @param string $name
* @return RedirectResponse
*/
public function disable(string $name): RedirectResponse
{
try {
$module = ModuleManager::find($name);
$module->disable();
$class = sprintf('\\%s\\%s\\%s', config('modules.namespace'), $module->getName(), $module->getName());
if (class_exists($class)) {
call_user_func([$class, 'uninstall']);
}
admin_success('Success', $name . '模块禁用成功');
} catch (\Exception $exception) {
admin_error('Error', $exception->getMessage());
}
return back();
}
/**
* Notes : 启用模块
*
* @Date : 2021/3/11 1:13 下午
* @Author : <Jason.C>
* @param string $name
* @return RedirectResponse
*/
public function enable(string $name): RedirectResponse
{
try {
$module = ModuleManager::find($name);
$module->enable();
$class = sprintf('\\%s\\%s\\%s', config('modules.namespace'), $module->getName(), $module->getName());
if (class_exists($class)) {
call_user_func([$class, 'install']);
}
admin_success('Success', $name . '模块启用成功');
} catch (\Exception $exception) {
admin_error('Error', $exception->getMessage());
}
return back();
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Admin\Extensions;
use Encore\Admin\Actions\Action;
use Encore\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
class CleanCache extends Action
{
protected $selector = '.clear-cache';
public function handle(Request $request): Response
{
Artisan::call('modelCache:clear');
return $this->response()->success('清理完成')->refresh();
}
public function dialog()
{
$this->confirm('确认清除缓存');
}
public function html(): string
{
return <<<HTML
<li>
<a class="clear-cache" href="#">
<i class="fa fa-trash"></i>
</a>
</li>
HTML;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Admin\Extensions;
use Encore\Admin\Form\Field;
class FormQrCode extends Field
{
protected $view = 'admin.form.qr_code';
public function render()
{
$google2fa = app('pragmarx.google2fa');
$this->value = $google2fa->getQRCodeUrl(
$this->data['username'],
$this->data['name'],
$this->data['g2fa_secret']
);
return parent::render();
}
}

View File

@@ -0,0 +1,12 @@
<?php
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
Route::group([
'prefix' => 'modules',
], function (Router $router) {
$router->get('', 'ModuleController@index');
$router->get('{name}/disable', 'ModuleController@disable')->name('module.disable');
$router->get('{name}/enable', 'ModuleController@enable')->name('module.enable');
});

View File

@@ -0,0 +1,94 @@
<?php
namespace App\Admin\Traits;
use Encore\Admin\Form;
use Encore\Admin\Form\Field\Image;
use Encore\Admin\Form\Field\MultipleFile;
use Encore\Admin\Form\Field\MultipleImage;
use Illuminate\Contracts\Support\Renderable;
trait WithUploads
{
/**
* Notes : 单张封面图上传
*
* @Date : 2021/4/25 2:06 下午
* @Author : <Jason.C>
* @param Form $form
* @param string $filed
* @param string $label
* @return Image
*/
public function cover(Renderable $form, string $filed = 'cover', string $label = '封面图片'): Image
{
$cover = $form->image($filed, $label)
->move('images/'.date('Y/m/d'))
->uniqueName()
->removable()
->retainable();
$waterConfig = config('admin.image_water');
if (! empty($waterConfig)) {
$cover->insert(...$waterConfig);
}
$coverThumb = config('admin.cover_thumb');
if (! empty($coverThumb)) {
$cover->thumbnail($coverThumb);
}
return $cover;
}
/**
* Notes : 统一的多图上传
*
* @Date : 2021/4/25 2:06 下午
* @Author : <Jason.C>
* @param Form $form
* @param string $filed
* @param string $label
* @return MultipleImage
*/
public function pictures(Renderable $form, string $filed = 'pictures', string $label = '多图轮播'): MultipleImage
{
$pictures = $form->multipleImage($filed, $label)
->move('images/'.date('Y/m/d'))
->uniqueName()
->removable()
->retainable();
// 多图如果开启排序的话,会报错,暂时没由解决办法 ->sortable()
$waterConfig = config('admin.image_water');
if (! empty($waterConfig)) {
$pictures->insert(...$waterConfig);
}
return $pictures;
}
/**
* Notes : 统一的附件上传
*
* @Date : 2021/4/25 3:03 下午
* @Author : <Jason.C>
* @param Renderable $form
* @param string $filed
* @param string $label
* @return MultipleFile
*/
public function attachments(
Renderable $form,
string $filed = 'attachments',
string $label = '内容附件'
): MultipleFile {
return $form->multipleFile($filed, $label)
->move('attachments/'.date('Y/m/d'))
->uniqueName()
->removable()
->retainable()
->sortable();
}
}

51
app/Admin/bootstrap.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
use App\Admin\Extensions\CleanCache;
use App\Admin\Extensions\FormQrCode;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Encore\Admin\Widgets\Navbar;
Form::forget(['map', 'editor']);
Admin::navbar(function (Navbar $navbar) {
$navbar->right(new CleanCache());
$navbar->right(new Navbar\Fullscreen());
});
Form::init(function (Form $form) {
$form->disableEditingCheck();
$form->disableCreatingCheck();
$form->disableViewCheck();
$form->tools(function (Form\Tools $tools) {
$tools->disableView();
// $tools->disableDelete();
// $tools->disableList();
});
});
Show::init(function (Show $show) {
$show->panel()
->tools(function ($tools) {
// $tools->disableEdit();
// $tools->disableList();
$tools->disableDelete();
});;
});
Grid::init(function (Grid $grid) {
$grid->disableExport();
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableView();
});
$grid->disableBatchActions();
$grid->filter(function ($filter) {
$filter->disableIdFilter();
});
// $grid->expandFilter();
});
Form::extend('qrCode', FormQrCode::class);

20
app/Admin/routes.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
use Encore\Admin\Facades\Admin;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
Admin::routes();
Route::group([
'prefix' => config('admin.route.prefix'),
'namespace' => config('admin.route.namespace'),
'middleware' => config('admin.route.middleware'),
'as' => config('admin.route.as'),
], function (Router $router) {
$router->get('/', 'HomeController@index')->name('home');
foreach (glob(admin_path('Routes') . '/*.php') as $routeFile) {
require $routeFile;
}
});

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Api\Controllers;
use Illuminate\Routing\Controller as BaseController;
use Jason\Api\Traits\ApiResponse;
class Controller extends BaseController
{
use ApiResponse;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Api\Controllers;
use Illuminate\Http\JsonResponse;
class IndexController extends Controller
{
public function index(): JsonResponse
{
return $this->success('Json Api is ready');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Api\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class BaseCollection extends ResourceCollection
{
protected function page(): array
{
return [
'current' => $this->currentPage(),
'total_page' => $this->lastPage(),
'per_page' => $this->perPage(),
'has_more' => $this->hasMorePages(),
'total' => $this->total(),
];
}
}

1
app/Api/bootstrap.php Normal file
View File

@@ -0,0 +1 @@
<?php

26
app/Api/routes.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
//Route::get('/', 'IndexController@index')->name('home');
/**
* 分组的路由示例
*/
Route::group([
// 'as' => '',
// 'domain' => '',
// 'middleware' => '',
// 'namespace' => '',
// 'prefix' => '',
], function (Router $router) {
$router->get('/', 'IndexController@index')->name('home');
});
/**
* 文件夹引入的示例
*/
//foreach (glob(app_path('Api/Routes') . '/*.php') as $routeFile) {
// require $routeFile;
//}

52
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Nwidart\Modules\Facades\Module as ModuleManager;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$this->modules($schedule);
}
/**
* 要执行任务的位置增加Console\Kernel类
* 类中 runCommand(Schedule $schedule)
* 模型中的command在模型的ServiceProvider自行注册
*
* @param Schedule $schedule
*/
protected function modules(Schedule $schedule)
{
$data = ModuleManager::toCollection();
foreach ($data as $name => $module) {
$class = "\\Modules\\$name\\Console\\Kernel";
if (class_exists($class)) {
$runKernel = resolve($class);
$runKernel->runCommand($schedule);
}
}
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
// $this->load(__DIR__.'/Commands');
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Jason\Api\Traits\ApiException;
use Throwable;
class Handler extends ExceptionHandler
{
use ApiException;
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use Jason\Api\Traits\ApiResponse;
class Controller extends BaseController
{
use ApiResponse;
/**
* Notes : 授权token返回格式
*
* @Date : 2021/3/16 5:00 下午
* @Author : <Jason.C>
* @param string $token
* @return array
*/
protected function respondWithToken(string $token): array
{
return [
'access_token' => $token,
'token_type' => 'Bearer',
'expires_in' => auth('api')->factory()->getTTL() * 60,
];
}
}

68
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,68 @@
<?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,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\SetServerId::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\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::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,
'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

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param Request $request
* @return string|null
*/
protected function redirectTo($request): ?string
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,17 @@
<?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

@@ -0,0 +1,17 @@
<?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

@@ -0,0 +1,34 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return Response|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

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class SetServerId
{
/**
* 设置响应的 server id便于故障判断
*
* @Author <Jason.C>
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$response->headers->add([
'X-Server-Id' => env('SERVER_ID'),
]);
return $response;
}
}

View File

@@ -0,0 +1,19 @@
<?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

@@ -0,0 +1,20 @@
<?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(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@@ -0,0 +1,28 @@
<?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

@@ -0,0 +1,17 @@
<?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 = [
//
];
}

45
app/Models/Google2FA.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class Google2FA extends Model
{
protected $casts = [
'status' => 'boolean',
];
public function subscriber(): MorphTo
{
return $this->morphTo();
}
/**
* Notes : 更新密钥
*
* @Date : 2022/11/30 20:51
* @Author : <Jason.C>
*/
public function upgrade()
{
$google2fa = app('pragmarx.google2fa');
$this->secret = $google2fa->generateSecretKey(32);
$this->save();
}
/**
* Notes : 验证
*
* @Date : 2022/11/30 20:49
* @Author : <Jason.C>
* @param string $value
* @return bool
*/
public function verify(string $value): bool
{
$google2fa = app('pragmarx.google2fa');
return $google2fa->verifyGoogle2FA($this->secret, $value);
}
}

27
app/Models/Model.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use App\Traits\Macroable;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Model extends Eloquent
{
use DefaultDatetimeFormat,
Macroable;
/**
* 禁止批量写入的字段
*
* @var array
*/
protected $guarded = [];
/**
* 修改模型默认分页数量为了配合API端使用的
*
* @var int
*/
protected $perPage = 10;
}

49
app/Models/Module.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Request;
use Nwidart\Modules\Facades\Module as ModuleManager;
class Module extends Model
{
/**
* Notes : 自定义返回数据
*
* @Date : 2021/3/11 9:59 上午
* @Author : <Jason.C>
* @return LengthAwarePaginator
*/
public function paginate(): LengthAwarePaginator
{
$perPage = Request::get('per_page', 20);
$page = Request::get('page', 1);
$data = ModuleManager::toCollection();
$chunk = $data->forPage($page, $perPage);
$modules = $chunk->map(function ($module) {
return [
'id' => $module->getName(),
'name' => $module->getName(),
'alias' => $module->getAlias(),
'description' => $module->getDescription(),
'priority' => $module->getPriority(),
'keywords' => $module->get('keywords'),
'requires' => $module->getRequires(),
'enabled' => $module->isEnabled(),
'version' => $module->get('version'),
'author' => $module->get('author'),
];
});
$modules = static::hydrate($modules->toArray());
$paginator = new LengthAwarePaginator($modules, ModuleManager::count(), $perPage);
$paginator->setPath(url()->current());
return $paginator;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View File

@@ -0,0 +1,21 @@
<?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

@@ -0,0 +1,32 @@
<?php
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;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->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(env('RATE_LIMITER', 60))->by(optional($request->user())->id ?: $request->ip());
});
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Rules;
use Encore\Admin\Auth\Database\Administrator;
use Illuminate\Contracts\Validation\Rule;
class AdminG2FARule implements Rule
{
protected array $formData;
protected string $errorMessage = '身份校验码 校验失败';
public function __construct(array $data)
{
$this->formData = $data;
}
public function passes($attribute, $value): bool
{
$user = Administrator::where('username', $this->formData['username'])->first();
if ($user && $user->use_g2fa) {
if (blank($value)) {
$this->errorMessage = '身份校验码 必须填写';
return false;
}
if (strlen($value) != 6) {
$this->errorMessage = '身份校验码 必须是6位';
return false;
}
$google2fa = app('pragmarx.google2fa');
return $google2fa->verifyGoogle2FA($user->g2fa_secret, $value);
}
return true;
}
public function message(): string
{
return $this->errorMessage;
}
}

69
app/Rules/IdCardRule.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class IdCardRule implements Rule
{
protected string $errorMessage = '身份证号码 校验错误';
/**
* Notes : 校验
*
* @Date : 2021/6/23 2:59 下午
* @Author : <Jason.C>
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value): bool
{
if (strlen($value) !== 18) {
$this->errorMessage = '请输入18位身份证号码';
return false;
}
return $this->isIdCard($value);
}
private function isIdCard($id): bool
{
$id = strtoupper($id);
$regx = "/(^\d{17}([0-9]|X)$)/";
$arr_split = [];
if (! preg_match($regx, $id)) {
return false;
}
$regx = "/^(\d{6})+(\d{4})+(\d{2})+(\d{2})+(\d{3})([0-9]|X)$/";
@preg_match($regx, $id, $arr_split);
$dtm_birth = $arr_split[2].'/'.$arr_split[3].'/'.$arr_split[4];
if (! strtotime($dtm_birth)) {
return false;
}
$arr_int = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
$arr_ch = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
$sign = 0;
for ($i = 0; $i < 17; $i++) {
$b = (int) $id[$i];
$w = $arr_int[$i];
$sign += $b * $w;
}
$n = $sign % 11;
$val_num = $arr_ch[$n];
return ! ($val_num !== substr($id, 17, 1));
}
/**
* 获取校验错误信息
*
* @return string
*/
public function message(): string
{
return $this->errorMessage;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
class OrderByIdDescScope implements Scope
{
/**
* Notes : ID倒序的作用域
*
* @Date : 2021/11/10 10:16 上午
* @Author : <Jason.C>
* @param Builder $builder
* @param Model $model
*/
public function apply(Builder $builder, Model $model): void
{
$builder->orderByDesc('id');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
class OrderByOrderAscScope implements Scope
{
/**
* Notes : 按照 order 字段 正序排序的作用域
*
* @Date : 2021/11/10 10:16 上午
* @Author : <Jason.C>
* @param Builder $builder
* @param Model $model
*/
public function apply(Builder $builder, Model $model): void
{
$builder->orderBy('order')->orderByDesc('id');
}
}

87
app/Traits/HasClicks.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
namespace App\Traits;
use Illuminate\Support\Facades\Cache;
/**
* 预期给所有拥有浏览计数的模型使用
* 使用缓存,计算浏览量,定期更新缓存至数据库中
*/
trait HasClicks
{
protected int $saveRate = 20;
/**
* Notes : 获取点击量的字段
*
* @Date : 2021/3/17 9:39 上午
* @Author : <Jason.C>
* @return string
*/
private function getClicksField(): string
{
return $this->clicks_filed ?? 'clicks';
}
/**
* Notes : 获取缓存前缀
*
* @Date : 2021/3/16 5:52 下午
* @Author : <Jason.C>
* @return string
*/
private function getClickCachePrefix(): string
{
return $this->cachePrefix ?? class_basename(__CLASS__);
}
/**
* Notes : 生成一个缓存KEY
*
* @Date : 2021/3/16 5:52 下午
* @Author : <Jason.C>
* @param string|null $appends
* @return string
*/
private function getCacheKey(string $appends = null): string
{
return $this->getClickCachePrefix().':'.$this->getKey().':'.$appends;
}
/**
* Notes : 增加点击量
*
* @Date : 2021/3/17 9:20 上午
* @Author : <Jason.C>
* @param int $step
*/
public function incrementClicks(int $step = 1): void
{
Cache::increment($this->getCacheKey('clicks'), $step);
if (rand(1, $this->saveRate) === 1) {
$this->update([$this->getClicksField() => $this->clicks]);
}
}
/**
* Notes : 获取缓存的浏览次数
*
* @Date : 2021/3/16 5:52 下午
* @Author : <Jason.C>
* @return int
*/
public function getClicksAttribute(): int
{
$clicks = Cache::get($this->getCacheKey('clicks'));
if (is_null($clicks)) {
return Cache::rememberForever($this->getCacheKey('clicks'), function () {
return $this->getAttributes()[$this->getClicksField()];
});
} else {
return $clicks;
}
}
}

86
app/Traits/HasCovers.php Normal file
View File

@@ -0,0 +1,86 @@
<?php
namespace App\Traits;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
trait HasCovers
{
/**
* Notes : 获取封面图片字段(单图)
*
* @Date : 2021/3/16 4:34 下午
* @Author : <Jason.C>
* @return string
*/
public function getCoverField(): string
{
return $this->cover_field ?? 'cover';
}
/**
* Notes : 获取图片字段(多图)
*
* @Date : 2021/3/16 4:35 下午
* @Author : <Jason.C>
* @return string
*/
public function getPicturesField(): string
{
return $this->pictures_field ?? 'pictures';
}
/**
* Notes : 解析单图地址
*
* @Date : 2021/3/16 4:54 下午
* @Author : <Jason.C>
* @return string
*/
public function getCoverUrlAttribute(): string
{
$cover = $this->getAttribute($this->getCoverField());
return $this->parseImageUrl($cover);
}
/**
* Notes : 解析多图地址
*
* @Date : 2021/3/16 4:54 下午
* @Author : <Jason.C>
* @return array
*/
public function getPicturesUrlAttribute(): array
{
$pictures = $this->getAttribute($this->getPicturesField());
if (empty($pictures)) {
return [];
}
return collect($pictures)->map(function ($picture) {
return $this->parseImageUrl($picture);
})->toArray();
}
/**
* Notes : 解析图片文件的实际展示地址
*
* @Date : 2021/3/16 4:53 下午
* @Author : <Jason.C>
* @param string|null $image
* @return string
*/
protected function parseImageUrl(?string $image): string
{
if (empty($image)) {
return '';
} elseif (Str::startsWith($image, 'http')) {
return $image;
} else {
return Storage::url($image);
}
}
}

91
app/Traits/HasStatus.php Normal file
View File

@@ -0,0 +1,91 @@
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
trait HasStatus
{
/**
* Notes : 获取状态字段,主模型可配置 $status_field
*
* @Date : 2021/3/16 4:34 下午
* @Author : <Jason.C>
* @return string
*/
protected function getStatusField(): string
{
return $this->status_field ?? 'status';
}
/**
* Notes : 获取各状态的名称
*
* @Date : 2021/5/27 11:50 上午
* @Author : <Jason.C>
* @return string[]
*/
protected function getStatusMap(): array
{
return isset($this->status_map) && ! empty($this->status_map) ? $this->status_map : [
0 => '待审核',
1 => '正常',
2 => '驳回',
3 => '关闭',
];
}
/**
* 正常显示的数据
*
* @Author:<Mr.Wang>
* @Date :2021-04-09
* @param Builder $query
* @return Builder
*/
public function scopeShown(Builder $query): Builder
{
return $query->where($this->getStatusField(), 1);
}
/**
* 不显示的数据
*
* @Author :<Mr.Wang>
* @Date :2021-04-09
* @param Builder $query
* @return Builder
*/
public function scopeHidden(Builder $query): Builder
{
return $query->where($this->getStatusField(), 0);
}
/**
* Notes : 状态查询
*
* @Date : 2021/6/28 10:25 上午
* @Author : <Jason.C>
* @param Builder $query
* @param int $status
* @return Builder
*/
public function scopeOfStatus(Builder $query, int $status): Builder
{
return $query->where($this->getStatusField(), $status);
}
/**
* Notes : 获取状态的文本信息
*
* @Date : 2021/4/25 2:10 下午
* @Author : <Jason.C>
* @return string
*/
public function getStatusTextAttribute(): string
{
$map = $this->getStatusMap();
return $map[$this->{$this->getStatusField()}] ?? '未知';
}
}

48
app/Traits/Macroable.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Traits;
trait Macroable
{
use \Illuminate\Support\Traits\Macroable {
__call as macroCall;
}
/**
* @param string $key
* @return mixed
*/
public function getRelationValue($key)
{
$relation = parent::getRelationValue($key);
if (! $relation && static::hasMacro($key)) {
return $this->getRelationshipFromMethod($key);
}
return $relation;
}
/**
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}
return parent::__call($method, $parameters);
}
/**
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return parent::__callStatic($method, $parameters);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Traits;
use App\Scopes\OrderByIdDescScope;
trait OrderByIdDesc
{
/**
* Notes: 初始化trait自动在模型中注入作用域
* 需要对拥有排序的模型,不需要使用排序的时候
* Model::withoutGlobalScope(new OrderByIdDescScope)
*
* @Author: <C.Jason>
* @Date : 2020/1/19 1:42 下午
*/
public static function bootOrderByIdDesc(): void
{
static::addGlobalScope(new OrderByIdDescScope);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Traits;
use App\Scopes\OrderByIdDescScope;
use App\Scopes\OrderByOrderAscScope;
use Illuminate\Database\Eloquent\Builder;
trait OrderByOrderAsc
{
/**
* Notes: 初始化trait自动在模型中注入作用域
* 取消排序参考 OrderByIdDesc
*
* @Author: <C.Jason>
* @Date : 2020/1/19 1:42 下午
*/
public static function bootOrderByOrderAsc(): void
{
static::addGlobalScope(new OrderByOrderAscScope());
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Traits;
use App\Models\Google2FA;
use Illuminate\Database\Eloquent\Relations\MorphOne;
trait WithGoogle2FA
{
public static function bootWithGoogle2FA()
{
self::created(function ($model) {
$google2fa = app('pragmarx.google2fa');
$model->google2fa()->create([
'secret' => $google2fa->generateSecretKey(32),
]);
});
}
public function google2fa(): MorphOne
{
return $this->morphOne(Google2FA::class, 'subscriber');
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
trait WithPosition
{
/**
* Notes : 获取定位的数组
*
* @Date : 2021/7/2 11:31 上午
* @Author : <Jason.C>
*/
protected function getPositionMap(): array
{
return $this->position_map ?? [];
}
/**
* Notes: 定位查询作用域
*
* @Author: Mr.wang
* @Date : 2021/5/11 10:48
* @param Builder $query
* @param int $pos
* @return Builder
*/
public function scopeOfPosition(Builder $query, int $pos): Builder
{
return $query->whereRaw('position & '.$pos);
}
/**
* Notes: 设置定位
*
* @Author: Mr.wang
* @Date : 2020/5/11 10:48
* @param array $value
*/
protected function setPositionAttribute(array $value): void
{
if (! blank($value)) {
$this->attributes['position'] = array_sum($value);
}
}
/**
* Notes: 获取定位数据
*
* @Author: Mr.wang
* @Date : 2020/5/11 10:48
* @param int $value
* @return array
*/
protected function getPositionAttribute(int $value): array
{
$position = [];
foreach ($this->getPositionMap() as $k => $v) {
if ($k & $value) {
$position[] = $k;
}
}
return $position;
}
}

53
artisan Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| 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 our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| 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);

55
bootstrap/app.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| 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.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| 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.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| 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.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View File

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

75
composer.json Normal file
View File

@@ -0,0 +1,75 @@
{
"name": "uztech/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.4|^8.0",
"ext-json": "*",
"encore/laravel-admin": "^1.8.16",
"fideloper/proxy": "^4.4.1",
"fruitcake/laravel-cors": "^2.0.4",
"genealabs/laravel-model-caching": "^0.11.3",
"guzzlehttp/guzzle": "^7.4.0",
"jasonc/api": "^5.0.4",
"laravel/framework": "^8.71.0",
"laravel/sanctum": "^2.12.2",
"nosun/ueditor": "^3.0.2",
"nwidart/laravel-modules": "^8.2.0",
"pragmarx/google2fa-laravel": "^2.0",
"simplesoftwareio/simple-qrcode": "^4.2"
},
"require-dev": {
"facade/ignition": "^2.16.0",
"fakerphp/faker": "^1.16.0",
"laravel/sail": "^1.12.4",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10.0",
"phpunit/phpunit": "^9.5.10",
"wulfheart/pretty_routes": "^0.3.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"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"
]
}
}

10220
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

412
config/admin.php Normal file
View File

@@ -0,0 +1,412 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 上传图片的水印设置
| [
| storage_path('app/water.png'), 水印图片
| 'bottom-right', 水印位置
| 20, 相对偏移 x
| 20, 相对偏移 y
| ]
|--------------------------------------------------------------------------
*/
'image_water' => [
// storage_path('app/water.png'),
// 'bottom-right',
],
/*
|--------------------------------------------------------------------------
| 上传图片是否开启缩略图
| 'small' => [100, 100],
| ...
|--------------------------------------------------------------------------
*/
'cover_thumb' => [],
/*
|--------------------------------------------------------------------------
| Laravel-admin name
|--------------------------------------------------------------------------
|
| This value is the name of laravel-admin, This setting is displayed on the
| login page.
|
*/
'name' => env('ADMIN_NAME', 'Jason-admin'),
/*
|--------------------------------------------------------------------------
| Laravel-admin html title
|--------------------------------------------------------------------------
|
| Html title for all pages.
|
*/
'title' => env('ADMIN_TITLE', 'Jason Admin'),
/*
|--------------------------------------------------------------------------
| Laravel-admin logo
|--------------------------------------------------------------------------
|
| The logo of all admin pages. You can also set it as an image by using a
| `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo' => env('ADMIN_LOGO', '<b>Jason</b> admin'),
/*
|--------------------------------------------------------------------------
| Laravel-admin mini logo
|--------------------------------------------------------------------------
|
| The logo of all admin pages when the sidebar menu is collapsed. You can
| also set it as an image by using a `img` tag, eg
| '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo-mini' => env('ADMIN_LOGO_MINI', '<b>JA</b>'),
/*
|--------------------------------------------------------------------------
| Laravel-admin bootstrap setting
|--------------------------------------------------------------------------
|
| This value is the path of laravel-admin bootstrap file.
|
*/
'bootstrap' => app_path('Admin/bootstrap.php'),
/*
|--------------------------------------------------------------------------
| Laravel-admin route settings
|--------------------------------------------------------------------------
|
| The routing configuration of the admin page, including the path prefix,
| the controller namespace, and the default middleware. If you want to
| access through the root path, just set the prefix to empty string.
|
*/
'route' => [
'prefix' => env('ADMIN_ROUTE_PREFIX', 'admin'),
'namespace' => 'App\\Admin\\Controllers',
'middleware' => ['web', 'admin'],
'as' => 'admin.',
],
/*
|--------------------------------------------------------------------------
| Laravel-admin install directory
|--------------------------------------------------------------------------
|
| The installation directory of the controller and routing configuration
| files of the administration page. The default is `app/Admin`, which must
| be set before running `artisan admin::install` to take effect.
|
*/
'directory' => app_path('Admin'),
/*
|--------------------------------------------------------------------------
| Access via `https`
|--------------------------------------------------------------------------
|
| If your page is going to be accessed via https, set it to `true`.
|
*/
'https' => env('ADMIN_HTTPS', false),
/*
|--------------------------------------------------------------------------
| Laravel-admin auth setting
|--------------------------------------------------------------------------
|
| Authentication settings for all admin pages. Include an authentication
| guard and a user provider setting of authentication driver.
|
| You can specify a controller for `login` `logout` and other auth routes.
|
*/
'auth' => [
'controller' => App\Admin\Controllers\AuthController::class,
'guard' => 'admin',
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
'providers' => [
'admin' => [
'driver' => 'eloquent',
'model' => Encore\Admin\Auth\Database\Administrator::class,
],
],
// Add "remember me" to login form
'remember' => true,
// Redirect to the specified URI when user is not authorized.
'redirect_to' => 'auth/login',
// The URIs that should be excluded from authorization.
'excepts' => [
'auth/login',
'auth/logout',
],
],
/*
|--------------------------------------------------------------------------
| Laravel-admin upload setting
|--------------------------------------------------------------------------
|
| File system configuration for form upload files and images, including
| disk and upload path.
|
*/
'upload' => [
// Disk in `config/filesystem.php`.
'disk' => env('FILESYSTEM_DRIVER', 'local'),
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
/*
|--------------------------------------------------------------------------
| Laravel-admin database settings
|--------------------------------------------------------------------------
|
| Here are database settings for laravel-admin builtin model & tables.
|
*/
'database' => [
// Database connection for following tables.
'connection' => '',
// User tables and model.
'users_table' => 'admin_users',
'users_model' => Encore\Admin\Auth\Database\Administrator::class,
// Role table and model.
'roles_table' => 'admin_roles',
'roles_model' => Encore\Admin\Auth\Database\Role::class,
// Permission table and model.
'permissions_table' => 'admin_permissions',
'permissions_model' => Encore\Admin\Auth\Database\Permission::class,
// Menu table and model.
'menu_table' => 'admin_menu',
'menu_model' => Encore\Admin\Auth\Database\Menu::class,
// Pivot table for table above.
'operation_log_table' => 'admin_operation_log',
'user_permissions_table' => 'admin_user_permissions',
'role_users_table' => 'admin_role_users',
'role_permissions_table' => 'admin_role_permissions',
'role_menu_table' => 'admin_role_menu',
],
/*
|--------------------------------------------------------------------------
| User operation log setting
|--------------------------------------------------------------------------
|
| By setting this option to open or close operation log in laravel-admin.
|
*/
'operation_log' => [
'enable' => true,
/*
* Only logging allowed methods in the list
*/
'allowed_methods' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
/*
* Routes that will not log to database.
*
* All method to path like: admin/auth/logs
* or specific method to path like: get:admin/auth/logs.
*/
'except' => [
'admin/auth/logs*',
],
],
/*
|--------------------------------------------------------------------------
| Indicates whether to check route permission.
|--------------------------------------------------------------------------
*/
'check_route_permission' => true,
/*
|--------------------------------------------------------------------------
| Indicates whether to check menu roles.
|--------------------------------------------------------------------------
*/
'check_menu_roles' => true,
/*
|--------------------------------------------------------------------------
| User default avatar
|--------------------------------------------------------------------------
|
| Set a default avatar for newly created users.
|
*/
'default_avatar' => '/vendor/laravel-admin/AdminLTE/dist/img/user2-160x160.jpg',
/*
|--------------------------------------------------------------------------
| Admin map field provider
|--------------------------------------------------------------------------
|
| Supported: "tencent", "google", "yandex".
|
*/
'map_provider' => 'google',
/*
|--------------------------------------------------------------------------
| Application Skin
|--------------------------------------------------------------------------
|
| This value is the skin of admin pages.
| @see https://adminlte.io/docs/2.4/layout
|
| Supported:
| "skin-blue", "skin-blue-light", "skin-yellow", "skin-yellow-light",
| "skin-green", "skin-green-light", "skin-purple", "skin-purple-light",
| "skin-red", "skin-red-light", "skin-black", "skin-black-light".
|
*/
'skin' => 'skin-blue',
/*
|--------------------------------------------------------------------------
| Application layout
|--------------------------------------------------------------------------
|
| This value is the layout of admin pages.
| @see https://adminlte.io/docs/2.4/layout
|
| Supported: "fixed", "layout-boxed", "layout-top-nav", "sidebar-collapse",
| "sidebar-mini".
|
*/
'layout' => ['fixed', 'sidebar-mini'],
/*
|--------------------------------------------------------------------------
| Login page background image
|--------------------------------------------------------------------------
|
| This value is used to set the background image of login page.
|
*/
'login_background_image' => '',
/*
|--------------------------------------------------------------------------
| Show version at footer
|--------------------------------------------------------------------------
|
| Whether to display the version number of laravel-admin at the footer of
| each page
|
*/
'show_version' => true,
/*
|--------------------------------------------------------------------------
| Show environment at footer
|--------------------------------------------------------------------------
|
| Whether to display the environment at the footer of each page
|
*/
'show_environment' => true,
/*
|--------------------------------------------------------------------------
| Menu bind to permission
|--------------------------------------------------------------------------
|
| whether enable menu bind to a permission
*/
'menu_bind_permission' => true,
/*
|--------------------------------------------------------------------------
| Enable default breadcrumb
|--------------------------------------------------------------------------
|
| Whether enable default breadcrumb for every page content.
*/
'enable_default_breadcrumb' => true,
/*
|--------------------------------------------------------------------------
| Enable/Disable assets minify
|--------------------------------------------------------------------------
*/
'minify_assets' => [
// Assets will not be minified.
'excepts' => [
],
],
/*
|--------------------------------------------------------------------------
| Enable/Disable sidebar menu search
|--------------------------------------------------------------------------
*/
'enable_menu_search' => true,
/*
|--------------------------------------------------------------------------
| Alert message that will displayed on top of the page.
|--------------------------------------------------------------------------
*/
'top_alert' => '',
/*
|--------------------------------------------------------------------------
| The global Grid action display class.
|--------------------------------------------------------------------------
*/
'grid_action_class' => \Encore\Admin\Grid\Displayers\DropdownActions::class,
/*
|--------------------------------------------------------------------------
| Extension Directory
|--------------------------------------------------------------------------
|
| When you use command `php artisan admin:extend` to generate extensions,
| the extension files will be generated in this directory.
*/
'extension_dir' => app_path('Admin/Extensions'),
/*
|--------------------------------------------------------------------------
| Settings for extensions.
|--------------------------------------------------------------------------
|
| You can find all available extensions here
| https://github.com/laravel-admin-extensions.
|
*/
'extensions' => [
'ueditor' => [
// 如果要关掉这个扩展设置为false
'enable' => true,
// 编辑器的前端配置 参考http://fex.baidu.com/ueditor/#start-config
'config' => [
'initialFrameHeight' => 400, // 例如初始化高度
],
'field_type' => 'ueditor',
],
],
];

40
config/agent.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
return [
'route' => [
/**
* 可配置 API 独立域名
*/
'domain' => env('AGENT_ROUTE_DOMAIN', ''),
/**
* 不实用独立域名API 地址前缀
*/
'prefix' => env('AGENT_ROUTE_PREFIX', 'agent'),
/**
* API 控制器命名空间
*/
'namespace' => 'App\\Agent\\Controllers',
/**
* API 路由命名前缀
*/
'as' => 'agent.',
/**
* API 默认中间件
*/
'middleware' => ['api', 'api.accept'],
/**
* 身份认证的中间件
*/
'middleware_auth' => ['api', 'api.accept', 'token.auth'],
/**
* 获取token获取不到也不报错的中间件
*/
'middleware_guess' => ['api', 'api.accept', 'token.guess'],
],
/**
* API 目录
*/
'directory' => app_path('Agent'),
];

48
config/api.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
return [
/**
* 重新登录后自动作废以前的token
*/
'token_auto_revoke' => env('TOKEN_AUTO_REVOKE', true),
/**
* token的名称
*/
'passport_token_name' => env('PASSPORT_TOKEN_NAME', ''),
'route' => [
/**
* API 路由命名前缀
*/
'as' => 'api.',
/**
* 可配置 API 独立域名
*/
'domain' => env('API_ROUTE_DOMAIN', ''),
/**
* 不使用用独立域名API 地址前缀
*/
'prefix' => env('API_ROUTE_PREFIX', 'api'),
/**
* API 控制器命名空间
*/
'namespace' => 'App\\Api\\Controllers',
/**
* 中间件
*/
'middleware' => ['api', 'api.accept'],
/**
* 身份认证的中间件
*/
'middleware_auth' => ['api', 'api.accept', 'token.auth'],
/**
* 获取token获取不到也不报错的中间件
*/
'middleware_guess' => ['api', 'api.accept', 'token.guess'],
],
/**
* 接口目录
*/
'directory' => app_path('Api'),
];

235
config/app.php Normal file
View File

@@ -0,0 +1,235 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Asia/Shanghai',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'zh_CN',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'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',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| 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' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Js' => Illuminate\Support\Js::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
// 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
];

111
config/auth.php Normal file
View File

@@ -0,0 +1,111 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| 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 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,
];

64
config/broadcasting.php Normal file
View File

@@ -0,0 +1,64 @@
<?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' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

106
config/cache.php Normal file
View File

@@ -0,0 +1,106 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| 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", "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',
],
'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'),
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| 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', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
];

34
config/cors.php Normal file
View File

@@ -0,0 +1,34 @@
<?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/*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => ['Authorization', '*'],
'max_age' => 0,
'supports_credentials' => false,
];

147
config/database.php Normal file
View File

@@ -0,0 +1,147 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'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'),
'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'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'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,
'schema' => 'public',
'sslmode' => '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,
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| 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
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

82
config/filesystems.php Normal file
View File

@@ -0,0 +1,82 @@
<?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_DRIVER', '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 setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'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'),
],
'oss' => [
'driver' => 'oss',
'root' => '',
'access_key' => env('OSS_ACCESS_KEY'),
'secret_key' => env('OSS_SECRET_KEY'),
'endpoint' => env('OSS_ENDPOINT'),
'bucket' => env('OSS_BUCKET'),
'isCName' => env('OSS_IS_CNAME', false),
'cdnHost' => env('OSS_CDN_HOST'),
],
],
/*
|--------------------------------------------------------------------------
| 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'),
],
];

52
config/hashing.php Normal file
View File

@@ -0,0 +1,52 @@
<?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' => 1024,
'threads' => 2,
'time' => 2,
],
];

20
config/image.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'gd'
];

View File

@@ -0,0 +1,11 @@
<?php
return [
'cache-prefix' => '',
'enabled' => env('MODEL_CACHE_ENABLED', true),
'use-database-keying' => env('MODEL_CACHE_USE_DATABASE_KEYING', true),
'store' => env('MODEL_CACHE_STORE'),
];

117
config/logging.php Normal file
View File

@@ -0,0 +1,117 @@
<?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' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
/*
|--------------------------------------------------------------------------
| 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' => ['daily'],
'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' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'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'),
],
],
];

110
config/mail.php Normal file
View File

@@ -0,0 +1,110 @@
<?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"
|
*/
'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,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
/*
|--------------------------------------------------------------------------
| 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'),
],
],
];

272
config/modules.php Normal file
View File

@@ -0,0 +1,272 @@
<?php
use Nwidart\Modules\Activators\FileActivator;
use Nwidart\Modules\Commands;
return [
/*
|--------------------------------------------------------------------------
| Module Namespace
|--------------------------------------------------------------------------
|
| Default module namespace.
|
*/
'namespace' => 'Modules',
/*
|--------------------------------------------------------------------------
| Module Stubs
|--------------------------------------------------------------------------
|
| Default module stubs.
|
*/
'stubs' => [
'enabled' => false,
'path' => base_path() . '/vendor/nwidart/laravel-modules/src/Commands/stubs',
'files' => [
'routes/web' => 'Routes/web.php',
'routes/api' => 'Routes/api.php',
'views/index' => 'Resources/views/index.blade.php',
'views/master' => 'Resources/views/layouts/master.blade.php',
'scaffold/config' => 'Config/config.php',
'composer' => 'composer.json',
'assets/js/app' => 'Resources/assets/js/app.js',
'assets/sass/app' => 'Resources/assets/sass/app.scss',
'webpack' => 'webpack.mix.js',
'package' => 'package.json',
],
'replacements' => [
'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'],
'routes/api' => ['LOWER_NAME'],
'webpack' => ['LOWER_NAME'],
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'],
'views/index' => ['LOWER_NAME'],
'views/master' => ['LOWER_NAME', 'STUDLY_NAME'],
'scaffold/config' => ['STUDLY_NAME'],
'composer' => [
'LOWER_NAME',
'STUDLY_NAME',
'VENDOR',
'AUTHOR_NAME',
'AUTHOR_EMAIL',
'MODULE_NAMESPACE',
'PROVIDER_NAMESPACE',
],
],
'gitkeep' => false,
],
'paths' => [
/*
|--------------------------------------------------------------------------
| Modules path
|--------------------------------------------------------------------------
|
| This path used for save the generated module. This path also will be added
| automatically to list of scanned folders.
|
*/
'modules' => base_path('modules'),
/*
|--------------------------------------------------------------------------
| Modules assets path
|--------------------------------------------------------------------------
|
| Here you may update the modules assets path.
|
*/
'assets' => public_path('modules'),
/*
|--------------------------------------------------------------------------
| The migrations path
|--------------------------------------------------------------------------
|
| Where you run 'module:publish-migration' command, where do you publish the
| the migration files?
|
*/
'migration' => base_path('database/migrations'),
/*
|--------------------------------------------------------------------------
| Generator path
|--------------------------------------------------------------------------
| Customise the paths where the folders will be generated.
| Set the generate key to false to not generate that folder
*/
'generator' => [
'config' => ['path' => 'Config', 'generate' => true],
'command' => ['path' => 'Console', 'generate' => true],
'migration' => ['path' => 'Database/Migrations', 'generate' => true],
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
'factory' => ['path' => 'Database/factories', 'generate' => true],
'model' => ['path' => 'Models', 'generate' => true],
'routes' => ['path' => 'Routes', 'generate' => true],
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
'request' => ['path' => 'Http/Requests', 'generate' => true],
'provider' => ['path' => 'Providers', 'generate' => true],
'assets' => ['path' => 'Resources/assets', 'generate' => false],
'lang' => ['path' => 'Resources/lang', 'generate' => true],
'views' => ['path' => 'Resources/views', 'generate' => false],
'test' => ['path' => 'Tests/Unit', 'generate' => false],
'test-feature' => ['path' => 'Tests/Feature', 'generate' => false],
'repository' => ['path' => 'Http/Resources', 'generate' => true],
'event' => ['path' => 'Events', 'generate' => true],
'listener' => ['path' => 'Listeners', 'generate' => true],
'policies' => ['path' => 'Policies', 'generate' => false],
'rules' => ['path' => 'Rules', 'generate' => false],
'jobs' => ['path' => 'Jobs', 'generate' => true],
'emails' => ['path' => 'Emails', 'generate' => false],
'notifications' => ['path' => 'Notifications', 'generate' => false],
'resource' => ['path' => 'Transformers', 'generate' => false],
'component-view' => ['path' => 'Resources/views/components', 'generate' => false],
'component-class' => ['path' => 'View/Component', 'generate' => false],
],
],
/*
|--------------------------------------------------------------------------
| Package commands
|--------------------------------------------------------------------------
|
| Here you can define which commands will be visible and used in your
| application. If for example you don't use some of the commands provided
| you can simply comment them out.
|
*/
'commands' => [
Commands\CommandMakeCommand::class,
Commands\ControllerMakeCommand::class,
Commands\DisableCommand::class,
Commands\DumpCommand::class,
Commands\EnableCommand::class,
Commands\EventMakeCommand::class,
Commands\JobMakeCommand::class,
Commands\ListenerMakeCommand::class,
Commands\MailMakeCommand::class,
Commands\MiddlewareMakeCommand::class,
Commands\NotificationMakeCommand::class,
Commands\ProviderMakeCommand::class,
Commands\RouteProviderMakeCommand::class,
Commands\InstallCommand::class,
Commands\ListCommand::class,
Commands\ModuleDeleteCommand::class,
Commands\ModuleMakeCommand::class,
Commands\FactoryMakeCommand::class,
Commands\PolicyMakeCommand::class,
Commands\RequestMakeCommand::class,
Commands\RuleMakeCommand::class,
Commands\MigrateCommand::class,
Commands\MigrateRefreshCommand::class,
Commands\MigrateResetCommand::class,
Commands\MigrateRollbackCommand::class,
Commands\MigrateStatusCommand::class,
Commands\MigrationMakeCommand::class,
Commands\ModelMakeCommand::class,
Commands\PublishCommand::class,
Commands\PublishConfigurationCommand::class,
Commands\PublishMigrationCommand::class,
Commands\PublishTranslationCommand::class,
Commands\SeedCommand::class,
Commands\SeedMakeCommand::class,
Commands\SetupCommand::class,
Commands\UnUseCommand::class,
Commands\UpdateCommand::class,
Commands\UseCommand::class,
Commands\ResourceMakeCommand::class,
Commands\TestMakeCommand::class,
Commands\LaravelModulesV6Migrator::class,
],
/*
|--------------------------------------------------------------------------
| Scan Path
|--------------------------------------------------------------------------
|
| Here you define which folder will be scanned. By default will scan vendor
| directory. This is useful if you host the package in packagist website.
|
*/
'scan' => [
'enabled' => false,
'paths' => [
base_path('vendor/*/*'),
],
],
/*
|--------------------------------------------------------------------------
| Composer File Template
|--------------------------------------------------------------------------
|
| Here is the config for composer.json file, generated by this package
|
*/
'composer' => [
'vendor' => 'jasonc',
'author' => [
'name' => 'Jason.Chen',
'email' => 'chenjxlg@163.com',
],
],
'composer-output' => true,
/*
|--------------------------------------------------------------------------
| Caching
|--------------------------------------------------------------------------
|
| Here is the config for setting up caching feature.
|
*/
'cache' => [
'enabled' => false,
'key' => 'laravel-modules',
'lifetime' => 60,
],
/*
|--------------------------------------------------------------------------
| Choose what laravel-modules will register as custom namespaces.
| Setting one to false will require you to register that part
| in your own Service Provider class.
|--------------------------------------------------------------------------
*/
'register' => [
'translations' => true,
/**
* load files on boot or register method
* Note: boot not compatible with asgardcms
* @example boot|register
*/
'files' => 'register',
],
/*
|--------------------------------------------------------------------------
| Activators
|--------------------------------------------------------------------------
|
| You can define new types of activators here, file, database etc. The only
| required parameter is 'class'.
| The file activator will store the activation status in storage/installed_modules
*/
'activators' => [
'file' => [
'class' => FileActivator::class,
'statuses-file' => base_path('modules.json'),
'cache-key' => 'activator.installed',
'cache-lifetime' => 604800,
],
],
'activator' => 'file',
];

93
config/queue.php Normal file
View File

@@ -0,0 +1,93 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel'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'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| 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.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'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'),
'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,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

65
config/sanctum.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
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',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))),
/*
|--------------------------------------------------------------------------
| 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,
],
];

33
config/services.php Normal file
View File

@@ -0,0 +1,33 @@
<?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'),
],
'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'),
],
];

201
config/session.php Normal file
View File

@@ -0,0 +1,201 @@
<?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', null),
/*
|--------------------------------------------------------------------------
| 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', null),
/*
|--------------------------------------------------------------------------
| 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', null),
/*
|--------------------------------------------------------------------------
| 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 if it can not 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',
];

118
config/ueditor.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
/*
* This file is part of the overtrue/laravel-ueditor.
*
* (c) overtrue <i@overtrue.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return [
'hash_filename' => true,
// 存储引擎: config/filesystem.php 中 disks public 或 qiniu
'disk' => env('FILESYSTEM_DRIVER', 'local'),
'route' => [
'name' => '/ueditor/server',
'options' => [
// middleware => 'auth',
],
],
// 上传 配置
'upload' => [
/* 前后端通信相关的配置,注释只允许使用多行方式 */
/* 上传图片配置项 */
'imageActionName' => 'upload-image', /* 执行上传图片的action名称 */
'imageFieldName' => 'upfile', /* 提交的图片表单名称 */
'imageMaxSize' => 2 * 1024 * 1024, /* 上传大小限制单位B */
'imageAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 上传图片格式显示 */
'imageCompressEnable' => true, /* 是否压缩图片,默认是true */
'imageCompressBorder' => 1600, /* 图片压缩最长边限制 */
'imageInsertAlign' => 'none', /* 插入的图片浮动方式 */
'imageUrlPrefix' => '', /* 图片访问路径前缀 */
'imagePathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
/* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
/* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
/* {time} 会替换成时间戳 */
/* {yyyy} 会替换成四位年份 */
/* {yy} 会替换成两位年份 */
/* {mm} 会替换成两位月份 */
/* {dd} 会替换成两位日期 */
/* {hh} 会替换成两位小时 */
/* {ii} 会替换成两位分钟 */
/* {ss} 会替换成两位秒 */
/* 非法字符 \ => * ? " < > | */
/* 具请体看线上文档 => fex.baidu.com/assets/#use-format_upload_filename */
/* 涂鸦图片上传配置项 */
'scrawlActionName' => 'upload-scrawl', /* 执行上传涂鸦的action名称 */
'scrawlFieldName' => 'upfile', /* 提交的图片表单名称 */
'scrawlPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
'scrawlMaxSize' => 2048000, /* 上传大小限制单位B */
'scrawlUrlPrefix' => '', /* 图片访问路径前缀 */
'scrawlInsertAlign' => 'none',
/* 截图工具上传 */
'snapscreenActionName' => 'upload-image', /* 执行上传截图的action名称 */
'snapscreenPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
'snapscreenUrlPrefix' => '', /* 图片访问路径前缀 */
'snapscreenInsertAlign' => 'none', /* 插入的图片浮动方式 */
/* 抓取远程图片配置 */
'catcherLocalDomain' => ['127.0.0.1', 'localhost', 'img.baidu.com'],
'catcherActionName' => 'catch-image', /* 执行抓取远程图片的action名称 */
'catcherFieldName' => 'source', /* 提交的图片列表表单名称 */
'catcherPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
'catcherUrlPrefix' => '', /* 图片访问路径前缀 */
'catcherMaxSize' => 2048000, /* 上传大小限制单位B */
'catcherAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 抓取图片格式显示 */
/* 上传视频配置 */
'videoActionName' => 'upload-video', /* 执行上传视频的action名称 */
'videoFieldName' => 'upfile', /* 提交的视频表单名称 */
'videoPathFormat' => '/uploads/videos/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
'videoUrlPrefix' => '', /* 视频访问路径前缀 */
'videoMaxSize' => 102400000, /* 上传大小限制单位B默认100MB */
'videoAllowFiles' => [
'.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg',
'.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid',
], /* 上传视频格式显示 */
/* 上传文件配置 */
'fileActionName' => 'upload-file', /* controller里,执行上传视频的action名称 */
'fileFieldName' => 'upfile', /* 提交的文件表单名称 */
'filePathFormat' => '/uploads/files/{yyyy}/{mm}/{dd}/', /* 上传保存路径,可以自定义保存路径和文件名格式 */
'fileUrlPrefix' => '', /* 文件访问路径前缀 */
'fileMaxSize' => 51200000, /* 上传大小限制单位B默认50MB */
'fileAllowFiles' => [
'.png', '.jpg', '.jpeg', '.gif', '.bmp',
'.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg',
'.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid',
'.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso',
'.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml',
], /* 上传文件格式显示 */
/* 列出指定目录下的图片 */
'imageManagerActionName' => 'list-image', /* 执行图片管理的action名称 */
'imageManagerListPath' => '/uploads/images/', /* 指定要列出图片的目录 */
'imageManagerListSize' => 20, /* 每次列出文件数量 */
'imageManagerUrlPrefix' => '', /* 图片访问路径前缀 */
'imageManagerInsertAlign' => 'none', /* 插入的图片浮动方式 */
'imageManagerAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 列出的文件类型 */
/* 列出指定目录下的文件 */
'fileManagerActionName' => 'list-file', /* 执行文件管理的action名称 */
'fileManagerListPath' => '/uploads/files/', /* 指定要列出文件的目录 */
'fileManagerUrlPrefix' => '', /* 文件访问路径前缀 */
'fileManagerListSize' => 20, /* 每次列出文件数量 */
'fileManagerAllowFiles' => [
'.png', '.jpg', '.jpeg', '.gif', '.bmp',
'.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg',
'.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid',
'.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso',
'.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml',
], /* 列出的文件类型 */
],
];

36
config/view.php Normal file
View File

@@ -0,0 +1,36 @@
<?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'))
),
];

2
database/.gitignore vendored Normal file
View File

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

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View File

@@ -0,0 +1,119 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAdminTables extends Migration
{
/**
* {@inheritdoc}
*/
public function getConnection()
{
return config('admin.database.connection') ?: config('database.default');
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('username', 190)->unique();
$table->string('password', 60);
$table->string('name');
$table->string('avatar')->nullable();
$table->string('remember_token', 100)->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.roles_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->timestamps();
});
Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->string('http_method')->nullable();
$table->text('http_path')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->default(0);
$table->integer('order')->default(0);
$table->string('title', 50);
$table->string('icon', 50);
$table->string('uri')->nullable();
$table->string('permission')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('user_id');
$table->index(['role_id', 'user_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('permission_id');
$table->index(['role_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
$table->integer('user_id');
$table->integer('permission_id');
$table->index(['user_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('menu_id');
$table->index(['role_id', 'menu_id']);
$table->timestamps();
});
Schema::create(config('admin.database.operation_log_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('path');
$table->string('method', 10);
$table->string('ip');
$table->text('input');
$table->index('user_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists(config('admin.database.users_table'));
Schema::dropIfExists(config('admin.database.roles_table'));
Schema::dropIfExists(config('admin.database.permissions_table'));
Schema::dropIfExists(config('admin.database.menu_table'));
Schema::dropIfExists(config('admin.database.user_permissions_table'));
Schema::dropIfExists(config('admin.database.role_users_table'));
Schema::dropIfExists(config('admin.database.role_permissions_table'));
Schema::dropIfExists(config('admin.database.role_menu_table'));
Schema::dropIfExists(config('admin.database.operation_log_table'));
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePersonalAccessTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGoogle2fasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('google2fas', function (Blueprint $table) {
$table->id();
$table->morphs('subscriber');
$table->string('secret', 64)->nullable();
$table->boolean('status')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('google2fas');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Database\Seeders;
use Encore\Admin\Auth\Database\Administrator;
use Encore\Admin\Auth\Database\Menu;
use Encore\Admin\Auth\Database\Permission;
use Encore\Admin\Auth\Database\Role;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AdminPanelSeeder extends Seeder
{
/**
* Seed the application's database.
* @return void
*/
public function run()
{
Administrator::create([
'username' => 'admin',
'password' => bcrypt('admin'),
'name' => 'Administrator',
]);
Role::create([
'name' => 'Administrator',
'slug' => 'administrator',
]);
Permission::create([
'name' => 'All permission',
'slug' => '*',
'http_method' => '',
'http_path' => '*',
]);
Menu::create([
'id' => 1,
'parent_id' => 0,
'order' => 0,
'title' => 'Dashboard',
'icon' => 'fa-bar-chart',
'uri' => '/',
]);
$menu = Menu::create([
'id' => 2,
'parent_id' => 0,
'order' => 99,
'title' => 'Admin',
'icon' => 'fa-tasks',
]);
$menu->children()->createMany([
[
'parent_id' => 2,
'order' => 1,
'title' => '模块管理',
'icon' => 'fa-windows',
'uri' => 'modules',
],
[
'parent_id' => 2,
'order' => 2,
'title' => 'Users',
'icon' => 'fa-users',
'uri' => 'auth/users',
],
[
'parent_id' => 2,
'order' => 3,
'title' => 'Roles',
'icon' => 'fa-user',
'uri' => 'auth/roles',
],
[
'parent_id' => 2,
'order' => 4,
'title' => 'Permission',
'icon' => 'fa-ban',
'uri' => 'auth/permissions',
],
[
'parent_id' => 2,
'order' => 1,
'title' => 'Menu',
'icon' => 'fa-bars',
'uri' => 'auth/menu',
],
[
'parent_id' => 2,
'order' => 1,
'title' => 'Operation log',
'icon' => 'fa-history',
'uri' => 'auth/logs',
],
]);
DB::insert("INSERT INTO `admin_role_menu` VALUES (1, 2, NULL, NULL);");
DB::insert("INSERT INTO `admin_role_permissions` VALUES (1, 1, NULL, NULL);");
DB::insert("INSERT INTO `admin_role_users` VALUES (1, 1, NULL, NULL);");
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// \App\Models\User::factory(10)->create();
}
}

2
docs/READMD.md Normal file
View File

@@ -0,0 +1,2 @@
# Laravel 开发文档
<p align="center"><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"></p>

117
docs/Trait doc.md Normal file
View File

@@ -0,0 +1,117 @@
# Trait
## 1. HasClicks
> 缓存的浏览计数器
```php
use App\Traits\HasClicks;
class Test extends Model
{
use HasClicks;
protected string $clicks_filed = 'clicks';
}
$test = Test::first();
// 增加点击数量
$test->incrementClicks(1);
// 获取点击量
$test->clicks;
```
## 2. HasCovers
> 封面图与轮播图的展示扩展完整url
```php
use App\Traits\HasCovers;
class Test extends Model {
use HasCovers;
protected string $cover_field = 'cover';
protected string $pictures_field = 'pictures';
}
$test = Test::first();
$test->cover_url;
$test->pictures_url;
```
## 3. HasStatus
> 基础状态的显示与作用域查询
```php
use App\Traits\HasStatus;
class Test extends Model {
use HasStatus;
protected string $status_field = 'status';
protected array $status_map = [
1 => '正常',
0 => '禁用'
];
}
// 状态为 1 的
$test = Test::shown()->first();
// 状态为 0 的
$test = Test::hidden()->first();
// 查询特定状态
$test = Test::ofStatus(3)->first();
// 状态的文本显示
$test->status_text;
```
## 4. Macroable
> 这个主要用于,对模型的一些外部扩展使用、
>
> 因为模型无法动态的注入trait有些时候在模块外部需要写入关联模型等时候可以使用。
```php
use App\Tratis\Macroable;
class Test extends Model {
use Macroable;
}
// 对模型注入一个 address 的一对多关联
Test::macro('address', function () {
return $this->hasMany(Address::class);
});
```
## 5. OrderByIdDesc
> 直接引入模型后查询到的数据会默认以ID 倒序排列,
>
> 暂时没有找到怎么获取主键的方法,待升级
## 6. OrderByOrderAsc
> 已特定的 order 字段,按照升序排序
## 7. WithPosition
> 位运算来解决的多点定位,模型中需要有 position 字段
```php
use App\Traits\WithPosition;
class Test extends Model
{
use WithPosition;
protected array $position_map = [
1 => 'A',
2 => 'B',
4 => 'C',
8 => 'D',
];
}
$test = Test::ofPosition(3)->first();
```

9
init_composer.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
packages=$(php -f 'parseComposer.php')
if [ "$packages" != "" ];then
composer require $packages
fi
composer install --no-dev

2
modules.json Normal file
View File

@@ -0,0 +1,2 @@
{
}

11
modules/.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
*
!.gitignore
!pull-all.sh
!README.md
!Cms
!Configuration
!Mall
!Payment
!Storage
!Task
!User

4
modules/Cms/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.idea
vendor
.DS_Store
composer.lock

88
modules/Cms/Cms.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
namespace Modules\Cms;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Facade;
class Cms extends Facade
{
protected static string $mainTitle = '内容管理';
/**
* Notes : 模块初始化要做的一些操作
* @Date : 2021/3/12 11:34 上午
* @Author : < Jason.C >
*/
public static function install()
{
Artisan::call('migrate', [
'--path' => 'modules/Cms/Database/Migrations',
]);
self::createAdminMenu();
}
/**
* Notes : 卸载模块的一些操作
* @Date : 2021/3/12 11:35 上午
* @Author : < Jason.C >
*/
public static function uninstall()
{
$menu = config('admin.database.menu_model');
$mains = $menu::where('title', self::$mainTitle)->get();
foreach ($mains as $main) {
$main->delete();
}
}
protected static function createAdminMenu()
{
$menu = config('admin.database.menu_model');
$main = $menu::create([
'parent_id' => 0,
'order' => 15,
'title' => self::$mainTitle,
'icon' => 'fa-wordpress',
]);
$main->children()->createMany([
[
'order' => 1,
'title' => '文章管理',
'icon' => 'fa-bars',
'uri' => 'cms/articles',
],
[
'order' => 2,
'title' => '单页管理',
'icon' => 'fa-newspaper-o',
'uri' => 'cms/pages',
],
[
'order' => 3,
'title' => '分类管理',
'icon' => 'fa-indent',
'uri' => 'cms/categories',
],
[
'order' => 4,
'title' => '标签管理',
'icon' => 'fa-tags',
'uri' => 'cms/tags',
],
[
'order' => 5,
'title' => '素材管理',
'icon' => 'fa-adjust',
'uri' => 'cms/storages',
],
]);
}
}

View File

@@ -0,0 +1,10 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 模块名称
|--------------------------------------------------------------------------
*/
'name' => 'Cms',
];

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCmsArticleCategoryTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::create('cms_article_category', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('article_id');
$table->unsignedBigInteger('category_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_article_category');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCmsArticlesTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::create('cms_articles', function (Blueprint $table) {
$table->id();
$table->string('slug')->index()->nullable()->comment('唯一的别名');
$table->string('title');
$table->string('sub_title')->nullable()->comment('副标题');
$table->string('description')->nullable();
$table->string('cover')->nullable();
$table->json('pictures')->nullable();
$table->text('content');
$table->json('attachments')->nullable();
$table->boolean('status')->default(0);
$table->unsignedInteger('clicks')->default(0);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_articles');
}
}

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