From 7de5107c1416cf53d42a03582707e5b297706d07 Mon Sep 17 00:00:00 2001 From: jeffcott Date: Tue, 23 Feb 2021 14:44:36 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=AE=9A=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=80=86=E5=90=91migrate=E8=A1=A8=E7=BB=93=E6=9E=84=E5=8F=8A?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A8=E5=88=B0=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/Api/Tests/Feature/UserTest.php | 2 +- .../Console/MigrationGenerateCommand.php | 73 +- Modules/Common/Tests/Feature/BaseTestCase.php | 2 +- README.md | 6 +- app/Console/Kernel.php | 3 + artisan | 7 + composer.json | 2 + composer.lock | 811 +++++++++++++++++- .../2014_10_12_000000_create_users_table.php | 36 - ..._08_19_000000_create_failed_jobs_table.php | 36 - ...1_02_23_142754_create_admin_menu_table.php | 37 + ...42754_create_admin_operation_log_table.php | 36 + ...3_142754_create_admin_permission_table.php | 35 + ...3_142754_create_admin_role_menu_table.php} | 12 +- ...754_create_admin_role_permission_table.php | 33 + ...1_02_23_142754_create_admin_role_table.php | 33 + ...754_create_admin_user_permission_table.php | 33 + ...23_142754_create_admin_user_role_table.php | 33 + ...1_02_23_142754_create_admin_user_table.php | 36 + ...3_142754_create_password_resets_table.php} | 4 +- ...1_02_23_142754_create_tz_sms_log_table.php | 37 + ..._23_142754_create_tz_upload_file_table.php | 38 + ...2021_02_23_142754_create_tz_user_table.php | 35 + database/seeders/AdminMenuTableSeeder.php | 98 +++ .../seeders/AdminPermissionTableSeeder.php | 70 ++ database/seeders/AdminRoleMenuTableSeeder.php | 33 + .../AdminRolePermissionTableSeeder.php | 33 + database/seeders/AdminRoleTableSeeder.php | 28 + .../AdminUserPermissionTableSeeder.php | 18 + database/seeders/AdminUserRoleTableSeeder.php | 33 + database/seeders/AdminUserTableSeeder.php | 31 + database/seeders/DatabaseSeeder.php | 10 +- database/seeders/TzUserTableSeeder.php | 30 + helpers/time.php | 8 +- 34 files changed, 1658 insertions(+), 114 deletions(-) delete mode 100644 database/migrations/2014_10_12_000000_create_users_table.php delete mode 100644 database/migrations/2019_08_19_000000_create_failed_jobs_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_menu_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_operation_log_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_permission_table.php rename database/migrations/{2021_02_06_085218_create_upload_files_table.php => 2021_02_23_142754_create_admin_role_menu_table.php} (53%) create mode 100644 database/migrations/2021_02_23_142754_create_admin_role_permission_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_role_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_user_permission_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_user_role_table.php create mode 100644 database/migrations/2021_02_23_142754_create_admin_user_table.php rename database/migrations/{2014_10_12_100000_create_password_resets_table.php => 2021_02_23_142754_create_password_resets_table.php} (84%) create mode 100644 database/migrations/2021_02_23_142754_create_tz_sms_log_table.php create mode 100644 database/migrations/2021_02_23_142754_create_tz_upload_file_table.php create mode 100644 database/migrations/2021_02_23_142754_create_tz_user_table.php create mode 100644 database/seeders/AdminMenuTableSeeder.php create mode 100644 database/seeders/AdminPermissionTableSeeder.php create mode 100644 database/seeders/AdminRoleMenuTableSeeder.php create mode 100644 database/seeders/AdminRolePermissionTableSeeder.php create mode 100644 database/seeders/AdminRoleTableSeeder.php create mode 100644 database/seeders/AdminUserPermissionTableSeeder.php create mode 100644 database/seeders/AdminUserRoleTableSeeder.php create mode 100644 database/seeders/AdminUserTableSeeder.php create mode 100644 database/seeders/TzUserTableSeeder.php diff --git a/Modules/Api/Tests/Feature/UserTest.php b/Modules/Api/Tests/Feature/UserTest.php index a6c5e33d..7053269d 100644 --- a/Modules/Api/Tests/Feature/UserTest.php +++ b/Modules/Api/Tests/Feature/UserTest.php @@ -24,7 +24,7 @@ public function testLogin() { $url = $this->host . '/api/user/login'; $response = $this->withHeaders($this->header)->post($url, [ - 'username' => 'd729c0e7-e726-46c1-86f5-ccfd96c9acbf', + 'username' => '115fd8bb-d64e-47b2-89fa-21640927aeb2', 'password' => '102gzg9RBiLnOnwHx', ]); diff --git a/Modules/Common/Console/MigrationGenerateCommand.php b/Modules/Common/Console/MigrationGenerateCommand.php index c2fb5e1d..927efc3e 100644 --- a/Modules/Common/Console/MigrationGenerateCommand.php +++ b/Modules/Common/Console/MigrationGenerateCommand.php @@ -2,15 +2,21 @@ namespace Modules\Common\Console; +use Exception; +use Illuminate\Support\Str; use Illuminate\Console\Command; +use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Artisan; +use Orangehill\Iseed\TableNotFoundException; +use Symfony\Component\HttpFoundation\File\Exception\FileException; class MigrationGenerateCommand extends Command { - protected $signature = ''; + protected $signature = 'migrate:genAndSeed'; protected $description = ''; - protected $clearDays = '15'; + protected $clearDays = '5'; protected $tableMap = [ 'admin_menu', @@ -21,27 +27,82 @@ class MigrationGenerateCommand extends Command 'admin_user', 'admin_user_permission', 'admin_user_role', + 'tz_user', ]; public function handle() { - $this->createMigrations(); + if (true == $this->createMigrations()) { + $this->clearHistoryMigrations(); + } $this->seeds(); - - $this->clearHistoryMigrations(); } + /** + * @return bool + */ protected function createMigrations() { + try { + Artisan::call('migrate:generate', [ + '--no-interaction' => true, + ]); + $this->info('create migrations success'); + + return true; + } catch (Exception $exception) { + $this->error('create migrations error'); +// return $exception->getMessage(); + return false; + } } + /** + * @return bool + */ protected function seeds() { - $tableName = 'admin_role'; + try { + Artisan::call('iseed', [ + 'tables' => implode(',', $this->tableMap), + '--force' => true, + ]); + $this->info('create table seeders success'); + + return true; + } catch (TableNotFoundException $exception) { + // todo 加一个crontab的log-channel + $this->error('create table seeders error'); +// return $exception->getMessage(); + return false; + } } protected function clearHistoryMigrations() { + $dbPath = database_path('migrations'); + if (!File::exists($dbPath)) { + $this->error('database文件夹不存在'); + } + + try { + $d = File::files($dbPath); + + // 根据日期去删除文件,批量移除 + $days = beforeDaysFormatList($this->clearDays, 'Y_m_d'); + foreach (array_diff($days, [todayDate('Y_m_d')]) as $day) { + foreach ($d as $k) { + if (Str::startsWith($k->getRelativePathname(), $day)) { + File::delete($k->getPathname()); + } + } + } + $this->info('migration files delete success'); + + return true; + } catch (FileException $exception) { + throw new FileException('migration files delete error'); + } } } diff --git a/Modules/Common/Tests/Feature/BaseTestCase.php b/Modules/Common/Tests/Feature/BaseTestCase.php index 5ca1caaa..a9abaffd 100644 --- a/Modules/Common/Tests/Feature/BaseTestCase.php +++ b/Modules/Common/Tests/Feature/BaseTestCase.php @@ -75,7 +75,7 @@ private function userLogin() // todo 需要先注册 $url = $this->host . '/api/user/login'; $response = $this->withHeaders($this->header)->post($url, [ - 'username' => 'd729c0e7-e726-46c1-86f5-ccfd96c9acbf', + 'username' => '115fd8bb-d64e-47b2-89fa-21640927aeb2', 'password' => '102gzg9RBiLnOnwHx', ]); diff --git a/README.md b/README.md index 09685008..db6d32c5 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,10 @@ 1. *clone项目*。`gcl git@github.com:x1a0xv4n/laravel-starter.git` 2. *切换分支*。切换分支到对应laravel版本,master分支默认laravel最新版本`git checkout -b origin/target-version-branch` 3. *配置文件*。开发环境下,请复制`.env.prod`为`.env.dev`,并填写基本配置如数据库、redis、dingo等,如有问题,请发issue。 -4. *sql文件*。执行根目录下的`laravel_starter.sql` -5. *部署服务*。 +4. *sql文件* + 1. `migrate`生成表结构 + 2. `db:seed`写入配置表数据 +5. *部署服务* diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0c24f2cf..992bc1b5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,7 @@ use Illuminate\Console\Scheduling\Schedule; use Modules\Admin\Console\AdminInitCommand; +use Modules\Common\Console\MigrationGenerateCommand; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel @@ -15,6 +16,7 @@ class Kernel extends ConsoleKernel */ protected $commands = [ AdminInitCommand::class, + MigrationGenerateCommand::class, ]; /** @@ -25,6 +27,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { // $schedule->command('inspire')->hourly(); + $schedule->command(MigrationGenerateCommand::class)->daily(); } /** diff --git a/artisan b/artisan index 5c23e2e2..100d9242 100755 --- a/artisan +++ b/artisan @@ -30,6 +30,13 @@ $app = require_once __DIR__.'/bootstrap/app.php'; | */ +// .env配置多环境 +$app->detectEnvironment(function () use ($app) { + //获取默认env文件配置要加载的env文件名 + $envName = trim(file_get_contents($app->environmentPath() . '/.env')); + $app->loadEnvironmentFrom('.env.' . $envName); +}); + $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); $status = $kernel->handle( diff --git a/composer.json b/composer.json index 307fc055..6b801345 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,8 @@ "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.0", "nunomaduro/larastan": "^0.7.0", + "orangehill/iseed": "^3.0", + "oscarafdev/migrations-generator": "^2.0", "phpunit/phpunit": "^9.3.3" }, "config": { diff --git a/composer.lock b/composer.lock index bcfbadee..bf82bd36 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0dffd9937504da94b5d03a5e2ed76a85", + "content-hash": "388b7243341fa48e222b44921e784ca3", "packages": [ { "name": "asm89/stack-cors", @@ -6359,6 +6359,159 @@ } ], "packages-dev": [ + { + "name": "2bj/phanybar", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/2bj/Phanybar.git", + "reference": "88ff671e18f30c2047a34f8cf2465a7ff93c819b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/2bj/Phanybar/zipball/88ff671e18f30c2047a34f8cf2465a7ff93c819b", + "reference": "88ff671e18f30c2047a34f8cf2465a7ff93c819b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "bin": [ + "bin/phanybar" + ], + "type": "library", + "autoload": { + "psr-4": { + "Bakyt\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bakyt Turgumbaev", + "email": "dev2bj@gmail.com" + } + ], + "description": "Control AnyBar from your php", + "keywords": [ + "anybar", + "phanybar" + ], + "support": { + "issues": "https://github.com/2bj/Phanybar/issues", + "source": "https://github.com/2bj/Phanybar/tree/master" + }, + "time": "2015-03-06T12:14:28+00:00" + }, + { + "name": "codedungeon/php-cli-colors", + "version": "1.12.2", + "source": { + "type": "git", + "url": "https://github.com/mikeerickson/php-cli-colors.git", + "reference": "e346156f75717140a3dd622124d2ec686aa7ff8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikeerickson/php-cli-colors/zipball/e346156f75717140a3dd622124d2ec686aa7ff8e", + "reference": "e346156f75717140a3dd622124d2ec686aa7ff8e", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": ">=5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Codedungeon\\PHPCliColors\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike Erickson", + "email": "codedungeon@gmail.com" + } + ], + "description": "Liven up you PHP Console Apps with standard colors", + "homepage": "https://github.com/mikeerickson/php-cli-colors", + "keywords": [ + "color", + "colors", + "composer", + "package", + "php" + ], + "support": { + "issues": "https://github.com/mikeerickson/php-cli-colors/issues", + "source": "https://github.com/mikeerickson/php-cli-colors/tree/1.12.2" + }, + "time": "2021-01-05T04:48:27+00:00" + }, + { + "name": "codedungeon/phpunit-result-printer", + "version": "0.30.1", + "source": { + "type": "git", + "url": "https://github.com/mikeerickson/phpunit-pretty-result-printer.git", + "reference": "a361009eeb7078c1478ba835976f7722a4952870" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikeerickson/phpunit-pretty-result-printer/zipball/a361009eeb7078c1478ba835976f7722a4952870", + "reference": "a361009eeb7078c1478ba835976f7722a4952870", + "shasum": "" + }, + "require": { + "2bj/phanybar": "^1.0", + "codedungeon/php-cli-colors": "^1.10.2", + "hassankhan/config": "^0.11.2|^1.0|^2.0", + "php": "^7.1 | ^8.0", + "symfony/yaml": "^2.7|^3.0|^4.0|^5.0" + }, + "require-dev": { + "spatie/phpunit-watcher": "^1.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Codedungeon\\PHPUnitPrettyResultPrinter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike Erickson", + "email": "codedungeon@gmail.com" + } + ], + "description": "PHPUnit Pretty Result Printer", + "keywords": [ + "TDD", + "composer", + "package", + "phpunit", + "printer", + "result-printer", + "testing" + ], + "support": { + "issues": "https://github.com/mikeerickson/phpunit-pretty-result-printer/issues", + "source": "https://github.com/mikeerickson/phpunit-pretty-result-printer/tree/0.30.1" + }, + "time": "2020-12-24T20:19:03+00:00" + }, { "name": "composer/ca-bundle", "version": "1.2.9", @@ -6702,21 +6855,303 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4", - "reference": "f28d44c286812c714741478d968104c5e604a1d4", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4", + "reference": "f28d44c286812c714741478d968104c5e604a1d4", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/1.4.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-11-13T08:04:11+00:00" + }, + { + "name": "doctrine/cache", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "13e3381b25847283a91948d04640543941309727" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727", + "reference": "13e3381b25847283a91948d04640543941309727", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/1.10.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2020-07-07T18:54:01+00:00" + }, + { + "name": "doctrine/dbal", + "version": "2.12.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "adce7a954a1c2f14f85e94aed90c8489af204086" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/adce7a954a1c2f14f85e94aed90c8489af204086", + "reference": "adce7a954a1c2f14f85e94aed90c8489af204086", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.3 || ^8" + }, + "require-dev": { + "doctrine/coding-standard": "^8.1", + "jetbrains/phpstorm-stubs": "^2019.1", + "phpstan/phpstan": "^0.12.40", + "phpunit/phpunit": "^9.4", + "psalm/plugin-phpunit": "^0.10.0", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", + "vimeo/psalm": "^3.17.2" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/2.12.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2020-11-14T20:26:58+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9@dev" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { "psr-4": { - "Composer\\XdebugHandler\\": "src" + "Doctrine\\Common\\": "lib/Doctrine/Common" } }, "notification-url": "https://packagist.org/downloads/", @@ -6725,35 +7160,58 @@ ], "authors": [ { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" } ], - "description": "Restarts a process without Xdebug.", + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", "keywords": [ - "Xdebug", - "performance" + "event", + "event dispatcher", + "event manager", + "event system", + "events" ], "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.5" + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.1.x" }, "funding": [ { - "url": "https://packagist.com", + "url": "https://www.doctrine-project.org/sponsorship.html", "type": "custom" }, { - "url": "https://github.com/composer", - "type": "github" + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" }, { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", "type": "tidelift" } ], - "time": "2020-11-13T08:04:11+00:00" + "time": "2020-05-29T18:28:51+00:00" }, { "name": "doctrine/instantiator", @@ -7235,6 +7693,68 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "hassankhan/config", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hassankhan/config.git", + "reference": "62b0fd17540136efa94ab6b39f04044c6dc5e4a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hassankhan/config/zipball/62b0fd17540136efa94ab6b39f04044c6dc5e4a7", + "reference": "62b0fd17540136efa94ab6b39f04044c6dc5e4a7", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.36 || ~5.7 || ~6.5 || ~7.5", + "scrutinizer/ocular": "~1.1", + "squizlabs/php_codesniffer": "~2.2", + "symfony/yaml": "~3.4" + }, + "suggest": { + "symfony/yaml": "~3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Noodlehaus\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Hassan Khan", + "homepage": "http://hassankhan.me/", + "role": "Developer" + } + ], + "description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files", + "homepage": "http://hassankhan.me/config/", + "keywords": [ + "config", + "configuration", + "ini", + "json", + "microphp", + "unframework", + "xml", + "yaml", + "yml" + ], + "support": { + "issues": "https://github.com/hassankhan/config/issues", + "source": "https://github.com/hassankhan/config/tree/2.2.0" + }, + "time": "2020-12-07T16:04:15+00:00" + }, { "name": "justinrainbow/json-schema", "version": "5.2.10", @@ -7703,6 +8223,182 @@ ], "time": "2021-02-01T22:08:11+00:00" }, + { + "name": "orangehill/iseed", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/orangehill/iseed.git", + "reference": "874f77a20d49aa4c6c5fec2daf0daa070514e013" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/orangehill/iseed/zipball/874f77a20d49aa4c6c5fec2daf0daa070514e013", + "reference": "874f77a20d49aa4c6c5fec2daf0daa070514e013", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "php": "^7.2|^8.0" + }, + "require-dev": { + "illuminate/filesystem": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "laravel/framework": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "mockery/mockery": "^1.0.0", + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Orangehill\\Iseed\\IseedServiceProvider" + ] + } + }, + "autoload": { + "psr-0": { + "Orangehill\\Iseed": "src/" + }, + "classmap": [ + "src/Orangehill/Iseed/Exceptions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Tihomir Opacic", + "email": "tihomir.opacic@orangehilldev.com" + } + ], + "description": "Generate a new Laravel database seed file based on data from the existing database table.", + "keywords": [ + "artisan", + "generators", + "laravel", + "seed" + ], + "support": { + "issues": "https://github.com/orangehill/iseed/issues", + "source": "https://github.com/orangehill/iseed/tree/v3.0.1" + }, + "time": "2021-01-14T15:34:12+00:00" + }, + { + "name": "oscarafdev/laravel-4-generators", + "version": "3.2", + "source": { + "type": "git", + "url": "https://github.com/oscarafdev/Laravel-4-Generators.git", + "reference": "ddcc911cd230c0d1faa99af467a76028fdb971c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/oscarafdev/Laravel-4-Generators/zipball/ddcc911cd230c0d1faa99af467a76028fdb971c1", + "reference": "ddcc911cd230c0d1faa99af467a76028fdb971c1", + "shasum": "" + }, + "require": { + "illuminate/support": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "behat/behat": "^2.5.1", + "behat/mink": "^1.5.0", + "behat/mink-extension": "^1.2.0", + "behat/mink-goutte-driver": "^1.0.9", + "behat/mink-selenium2-driver": "^1.1.1", + "phpspec/phpspec": "^2.0", + "phpunit/phpunit": "^3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "Way\\Generators": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oscar Fernandez", + "email": "oscarafdev@gmail.com" + } + ], + "description": "Rapidly generate resources, migrations, models, and much more.", + "support": { + "source": "https://github.com/oscarafdev/Laravel-4-Generators/tree/3.2" + }, + "time": "2021-01-26T01:18:41+00:00" + }, + { + "name": "oscarafdev/migrations-generator", + "version": "2.0.24", + "source": { + "type": "git", + "url": "https://github.com/oscarafdev/migrations-generator.git", + "reference": "8ffb09713d2f565c81f2c42e87748221a6afeb8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/oscarafdev/migrations-generator/zipball/8ffb09713d2f565c81f2c42e87748221a6afeb8b", + "reference": "8ffb09713d2f565c81f2c42e87748221a6afeb8b", + "shasum": "" + }, + "require": { + "doctrine/dbal": "~2.10", + "illuminate/support": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "oscarafdev/laravel-4-generators": "^3.1", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "illuminate/cache": ">=6.0", + "illuminate/console": ">=6.0", + "mockery/mockery": ">=1.0.3", + "phpunit/phpunit": ">=8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Way\\Generators\\GeneratorsServiceProvider", + "OscarAFDev\\MigrationsGenerator\\MigrationsGeneratorServiceProvider" + ] + } + }, + "autoload": { + "psr-0": { + "OscarAFDev\\MigrationsGenerator": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oscar Fernandez", + "email": "oscarafdev@gmail.com" + } + ], + "description": "Generates Laravel Migrations from an existing database", + "keywords": [ + "artisan", + "generator", + "laravel", + "migration", + "migrations" + ], + "support": { + "issues": "https://github.com/oscarafdev/migrations-generator/issues", + "source": "https://github.com/oscarafdev/migrations-generator/tree/2.0.24" + }, + "time": "2021-01-26T01:39:54+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.1", @@ -9699,6 +10395,81 @@ ], "time": "2021-01-27T10:01:46+00:00" }, + { + "name": "symfony/yaml", + "version": "v5.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/338cddc6d74929f6adf19ca5682ac4b8e109cdb0", + "reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<4.4" + }, + "require-dev": { + "symfony/console": "^4.4|^5.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v5.2.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-03T04:42:09+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.0", diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php deleted file mode 100644 index 9b79f1f7..00000000 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('users'); - } -} diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php deleted file mode 100644 index 7b4a35fc..00000000 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2021_02_23_142754_create_admin_menu_table.php b/database/migrations/2021_02_23_142754_create_admin_menu_table.php new file mode 100644 index 00000000..e95e9419 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_menu_table.php @@ -0,0 +1,37 @@ +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(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_menu'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_operation_log_table.php b/database/migrations/2021_02_23_142754_create_admin_operation_log_table.php new file mode 100644 index 00000000..1147e17f --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_operation_log_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->integer('user_id')->index(); + $table->string('path'); + $table->string('method', 10); + $table->string('ip'); + $table->text('input'); + $table->timestamps(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_operation_log'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_permission_table.php b/database/migrations/2021_02_23_142754_create_admin_permission_table.php new file mode 100644 index 00000000..5725392c --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_permission_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('name', 50)->unique('admin_permissions_name_unique'); + $table->string('slug', 50)->unique('admin_permissions_slug_unique'); + $table->string('http_method')->nullable(); + $table->text('http_path')->nullable(); + $table->timestamps(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_permission'); + } +} diff --git a/database/migrations/2021_02_06_085218_create_upload_files_table.php b/database/migrations/2021_02_23_142754_create_admin_role_menu_table.php similarity index 53% rename from database/migrations/2021_02_06_085218_create_upload_files_table.php rename to database/migrations/2021_02_23_142754_create_admin_role_menu_table.php index 2849c5dc..58a77b36 100644 --- a/database/migrations/2021_02_06_085218_create_upload_files_table.php +++ b/database/migrations/2021_02_23_142754_create_admin_role_menu_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateUploadFilesTable extends Migration +class CreateAdminRoleMenuTable extends Migration { /** * Run the migrations. @@ -13,9 +13,11 @@ class CreateUploadFilesTable extends Migration */ public function up() { - Schema::create('upload_files', function (Blueprint $table) { - $table->id(); - $table->timestamps(); + Schema::create('admin_role_menu', function (Blueprint $table) { + $table->integer('role_id'); + $table->integer('menu_id'); + $table->timestamps(10); + $table->index(['role_id', 'menu_id']); }); } @@ -26,6 +28,6 @@ public function up() */ public function down() { - Schema::dropIfExists('upload_files'); + Schema::drop('admin_role_menu'); } } diff --git a/database/migrations/2021_02_23_142754_create_admin_role_permission_table.php b/database/migrations/2021_02_23_142754_create_admin_role_permission_table.php new file mode 100644 index 00000000..24ec8a26 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_role_permission_table.php @@ -0,0 +1,33 @@ +integer('role_id'); + $table->integer('permission_id'); + $table->timestamps(10); + $table->index(['role_id', 'permission_id'], 'admin_role_permissions_role_id_permission_id_index'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_role_permission'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_role_table.php b/database/migrations/2021_02_23_142754_create_admin_role_table.php new file mode 100644 index 00000000..e99f7fb8 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_role_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name', 50)->unique('admin_roles_name_unique'); + $table->string('slug', 50)->unique('admin_roles_slug_unique'); + $table->timestamps(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_role'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_user_permission_table.php b/database/migrations/2021_02_23_142754_create_admin_user_permission_table.php new file mode 100644 index 00000000..20a5452a --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_user_permission_table.php @@ -0,0 +1,33 @@ +integer('user_id'); + $table->integer('permission_id'); + $table->timestamps(10); + $table->index(['user_id', 'permission_id'], 'admin_user_permissions_user_id_permission_id_index'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_user_permission'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_user_role_table.php b/database/migrations/2021_02_23_142754_create_admin_user_role_table.php new file mode 100644 index 00000000..f19cc683 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_user_role_table.php @@ -0,0 +1,33 @@ +integer('role_id'); + $table->integer('user_id'); + $table->timestamps(10); + $table->index(['role_id', 'user_id'], 'admin_role_users_role_id_user_id_index'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_user_role'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_admin_user_table.php b/database/migrations/2021_02_23_142754_create_admin_user_table.php new file mode 100644 index 00000000..7c964138 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_admin_user_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('username', 190)->unique('admin_users_username_unique'); + $table->string('password', 60); + $table->string('name'); + $table->string('avatar')->nullable(); + $table->string('remember_token', 100)->nullable(); + $table->timestamps(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admin_user'); + } +} diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2021_02_23_142754_create_password_resets_table.php similarity index 84% rename from database/migrations/2014_10_12_100000_create_password_resets_table.php rename to database/migrations/2021_02_23_142754_create_password_resets_table.php index 0d5cb845..fbed3c96 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2021_02_23_142754_create_password_resets_table.php @@ -16,7 +16,7 @@ public function up() Schema::create('password_resets', function (Blueprint $table) { $table->string('email')->index(); $table->string('token'); - $table->timestamp('created_at')->nullable(); + $table->dateTime('created_at')->nullable(); }); } @@ -27,6 +27,6 @@ public function up() */ public function down() { - Schema::dropIfExists('password_resets'); + Schema::drop('password_resets'); } } diff --git a/database/migrations/2021_02_23_142754_create_tz_sms_log_table.php b/database/migrations/2021_02_23_142754_create_tz_sms_log_table.php new file mode 100644 index 00000000..450e24a6 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_tz_sms_log_table.php @@ -0,0 +1,37 @@ +integer('id', true); + $table->integer('user_id')->nullable()->comment('用户id'); + $table->string('mobile')->nullable(); + $table->string('content')->nullable()->comment('短信内容'); + $table->string('code')->nullable(); + $table->integer('type')->nullable()->comment('短信类型1注册2验证'); + $table->text('response')->nullable(); + $table->dateTime('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('tz_sms_log'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_tz_upload_file_table.php b/database/migrations/2021_02_23_142754_create_tz_upload_file_table.php new file mode 100644 index 00000000..10e1287e --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_tz_upload_file_table.php @@ -0,0 +1,38 @@ +integer('id', true); + $table->string('filename')->nullable()->comment('文件名'); + $table->string('category')->nullable(); + $table->string('ext')->nullable()->comment('文件后缀'); + $table->string('url')->nullable()->comment('七牛云url'); + $table->string('size')->nullable()->comment('文件大小'); + $table->string('md5')->nullable(); + $table->string('mime_type')->nullable()->comment('文件mime_type'); + $table->dateTime('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('tz_upload_file'); + } +} diff --git a/database/migrations/2021_02_23_142754_create_tz_user_table.php b/database/migrations/2021_02_23_142754_create_tz_user_table.php new file mode 100644 index 00000000..bda5b038 --- /dev/null +++ b/database/migrations/2021_02_23_142754_create_tz_user_table.php @@ -0,0 +1,35 @@ +bigInteger('id', true)->unsigned(); + $table->string('username'); + $table->string('mobile')->nullable()->comment('手机号'); + $table->string('password')->nullable(); + $table->string('remember_token', 100)->nullable(); + $table->timestamps(10); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('tz_user'); + } +} diff --git a/database/seeders/AdminMenuTableSeeder.php b/database/seeders/AdminMenuTableSeeder.php new file mode 100644 index 00000000..4b4c9dc6 --- /dev/null +++ b/database/seeders/AdminMenuTableSeeder.php @@ -0,0 +1,98 @@ +delete(); + + \DB::table('admin_menu')->insert([ + 0 => [ + 'id' => 1, + 'parent_id' => 0, + 'order' => 1, + 'title' => 'Dashboard', + 'icon' => 'fa-bar-chart', + 'uri' => '/', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 1 => [ + 'id' => 2, + 'parent_id' => 0, + 'order' => 2, + 'title' => 'Admin', + 'icon' => 'fa-tasks', + 'uri' => '', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 2 => [ + 'id' => 3, + 'parent_id' => 2, + 'order' => 3, + 'title' => 'Users', + 'icon' => 'fa-users', + 'uri' => 'auth/users', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 3 => [ + 'id' => 4, + 'parent_id' => 2, + 'order' => 4, + 'title' => 'Roles', + 'icon' => 'fa-user', + 'uri' => 'auth/roles', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 4 => [ + 'id' => 5, + 'parent_id' => 2, + 'order' => 5, + 'title' => 'Permission', + 'icon' => 'fa-ban', + 'uri' => 'auth/permissions', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 5 => [ + 'id' => 6, + 'parent_id' => 2, + 'order' => 6, + 'title' => 'Menu', + 'icon' => 'fa-bars', + 'uri' => 'auth/menu', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + 6 => [ + 'id' => 7, + 'parent_id' => 2, + 'order' => 7, + 'title' => 'Operation log', + 'icon' => 'fa-history', + 'uri' => 'auth/logs', + 'permission' => null, + 'created_at' => null, + 'updated_at' => null, + ], + ]); + } +} diff --git a/database/seeders/AdminPermissionTableSeeder.php b/database/seeders/AdminPermissionTableSeeder.php new file mode 100644 index 00000000..fb616251 --- /dev/null +++ b/database/seeders/AdminPermissionTableSeeder.php @@ -0,0 +1,70 @@ +delete(); + + \DB::table('admin_permission')->insert([ + 0 => [ + 'id' => 1, + 'name' => 'All permission', + 'slug' => '*', + 'http_method' => '', + 'http_path' => '*', + 'created_at' => null, + 'updated_at' => null, + ], + 1 => [ + 'id' => 2, + 'name' => 'Dashboard', + 'slug' => 'dashboard', + 'http_method' => 'GET', + 'http_path' => '/', + 'created_at' => null, + 'updated_at' => null, + ], + 2 => [ + 'id' => 3, + 'name' => 'Login', + 'slug' => 'auth.login', + 'http_method' => '', + 'http_path' => '/auth/login +/auth/logout', + 'created_at' => null, + 'updated_at' => null, + ], + 3 => [ + 'id' => 4, + 'name' => 'User setting', + 'slug' => 'auth.setting', + 'http_method' => 'GET,PUT', + 'http_path' => '/auth/setting', + 'created_at' => null, + 'updated_at' => null, + ], + 4 => [ + 'id' => 5, + 'name' => 'Auth management', + 'slug' => 'auth.management', + 'http_method' => '', + 'http_path' => '/auth/roles +/auth/permissions +/auth/menu +/auth/logs', + 'created_at' => null, + 'updated_at' => null, + ], + ]); + } +} diff --git a/database/seeders/AdminRoleMenuTableSeeder.php b/database/seeders/AdminRoleMenuTableSeeder.php new file mode 100644 index 00000000..c3598336 --- /dev/null +++ b/database/seeders/AdminRoleMenuTableSeeder.php @@ -0,0 +1,33 @@ +delete(); + + \DB::table('admin_role_menu')->insert([ + 0 => [ + 'role_id' => 1, + 'menu_id' => 2, + 'created_at' => null, + 'updated_at' => null, + ], + 1 => [ + 'role_id' => 1, + 'menu_id' => 2, + 'created_at' => null, + 'updated_at' => null, + ], + ]); + } +} diff --git a/database/seeders/AdminRolePermissionTableSeeder.php b/database/seeders/AdminRolePermissionTableSeeder.php new file mode 100644 index 00000000..1701713d --- /dev/null +++ b/database/seeders/AdminRolePermissionTableSeeder.php @@ -0,0 +1,33 @@ +delete(); + + \DB::table('admin_role_permission')->insert([ + 0 => [ + 'role_id' => 1, + 'permission_id' => 1, + 'created_at' => null, + 'updated_at' => null, + ], + 1 => [ + 'role_id' => 1, + 'permission_id' => 1, + 'created_at' => null, + 'updated_at' => null, + ], + ]); + } +} diff --git a/database/seeders/AdminRoleTableSeeder.php b/database/seeders/AdminRoleTableSeeder.php new file mode 100644 index 00000000..63faa4af --- /dev/null +++ b/database/seeders/AdminRoleTableSeeder.php @@ -0,0 +1,28 @@ +delete(); + + \DB::table('admin_role')->insert([ + 0 => [ + 'id' => 1, + 'name' => 'Administrator', + 'slug' => 'administrator', + 'created_at' => '2021-02-07 09:24:47', + 'updated_at' => '2021-02-07 09:24:47', + ], + ]); + } +} diff --git a/database/seeders/AdminUserPermissionTableSeeder.php b/database/seeders/AdminUserPermissionTableSeeder.php new file mode 100644 index 00000000..d92c60f0 --- /dev/null +++ b/database/seeders/AdminUserPermissionTableSeeder.php @@ -0,0 +1,18 @@ +delete(); + } +} diff --git a/database/seeders/AdminUserRoleTableSeeder.php b/database/seeders/AdminUserRoleTableSeeder.php new file mode 100644 index 00000000..550ea64a --- /dev/null +++ b/database/seeders/AdminUserRoleTableSeeder.php @@ -0,0 +1,33 @@ +delete(); + + \DB::table('admin_user_role')->insert([ + 0 => [ + 'role_id' => 1, + 'user_id' => 1, + 'created_at' => null, + 'updated_at' => null, + ], + 1 => [ + 'role_id' => 1, + 'user_id' => 1, + 'created_at' => null, + 'updated_at' => null, + ], + ]); + } +} diff --git a/database/seeders/AdminUserTableSeeder.php b/database/seeders/AdminUserTableSeeder.php new file mode 100644 index 00000000..c4c4bb97 --- /dev/null +++ b/database/seeders/AdminUserTableSeeder.php @@ -0,0 +1,31 @@ +delete(); + + \DB::table('admin_user')->insert([ + 0 => [ + 'id' => 1, + 'username' => 'admin', + 'password' => '$2y$10$7kMHGQV5jo0qsMEOpOW4M.AmqobLb3ouOU0yjc7i50vFf.tq8QqTi', + 'name' => 'Administrator', + 'avatar' => null, + 'remember_token' => 'vNi31McdRq3iGqTLYuNP9TXBRqfB5HDn3QsyU79lEIaBsbbyBAJOWmXZt8Jm', + 'created_at' => '2021-02-07 09:24:46', + 'updated_at' => '2021-02-07 09:24:46', + ], + ]); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 57b73b54..52fc4deb 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,6 +13,14 @@ class DatabaseSeeder extends Seeder */ public function run() { - // \App\Models\User::factory(10)->create(); + $this->call(AdminMenuTableSeeder::class); + $this->call(AdminPermissionTableSeeder::class); + $this->call(AdminRoleTableSeeder::class); + $this->call(AdminRoleMenuTableSeeder::class); + $this->call(AdminRolePermissionTableSeeder::class); + $this->call(AdminUserTableSeeder::class); + $this->call(AdminUserPermissionTableSeeder::class); + $this->call(AdminUserRoleTableSeeder::class); + $this->call(TzUserTableSeeder::class); } } diff --git a/database/seeders/TzUserTableSeeder.php b/database/seeders/TzUserTableSeeder.php new file mode 100644 index 00000000..9c4f8f00 --- /dev/null +++ b/database/seeders/TzUserTableSeeder.php @@ -0,0 +1,30 @@ +delete(); + + \DB::table('tz_user')->insert([ + 0 => [ + 'id' => 11, + 'username' => '115fd8bb-d64e-47b2-89fa-21640927aeb2', + 'mobile' => '18616287252', + 'password' => '$2y$04$uQwafMS5WrsPB7xi0ishUe6HK0qUyhQTsmff0NcYZDaaFQChJigfa', + 'remember_token' => null, + 'created_at' => '2021-02-23 11:07:43', + 'updated_at' => '2021-02-23 11:07:43', + ], + ]); + } +} diff --git a/helpers/time.php b/helpers/time.php index 45e6ed92..a56909ea 100644 --- a/helpers/time.php +++ b/helpers/time.php @@ -96,11 +96,11 @@ function afterDaysFormat($time, $num) /** * 列出之前n天的格式化时间,返回数组. */ - function beforeDaysFormatList(string $days, string $prefix = ''): array + function beforeDaysFormatList(int $days = 5, string $format = 'Y-m-d', string $prefix = ''): array { $dayArr = []; for ($i = 0; $i < $days; ++$i) { - $dayArr[$i] = $prefix . beforeNowFormat('day', $i); + $dayArr[$i] = $prefix . beforeNowFormat('day', $i, $format); } return $dayArr; @@ -132,9 +132,9 @@ function todayTimestamp() //今天;"2019-05-31" if (!function_exists('todayDate')) { - function todayDate() + function todayDate(string $format = 'Y-m-d'): string { - return date('Y-m-d', time()); + return date($format, time()); } }