This commit is contained in:
2023-01-11 11:00:43 +08:00
commit ff55141a1e
791 changed files with 177427 additions and 0 deletions

2
database/.gitignore vendored Normal file
View File

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

View File

@@ -0,0 +1,47 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
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,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFavoritesTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create(config('favorite.favorites_table'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger(config('favorite.user_foreign_key'))->index()->comment('user_id');
$table->morphs('favoriteable');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists(config('favorite.favorites_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,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create(config('subscribe.subscriptions_table'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger(config('subscribe.user_foreign_key'))->index()->comment('user_id');
$table->morphs('subscribable');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists(config('subscribe.subscriptions_table'));
}
}

View File

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

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBounsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bouns', function (Blueprint $table) {
$table->id();
$table->timestamp('date')->nullable()->comment('分红时间');
$table->string('type', 20)->comment('分红类别');
$table->unsignedDecimal('total', 12, 2)->default(0)->comment('分红累计金额');
$table->boolean('status')->default(0)->comment('分红状态');
$table->text('source')->nullable()->comment('数组源信息');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bouns');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBounsOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bouns_orders', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('bouns_id');
$table->morphs('order');
$table->string('type', 20)->comment('类别');
$table->unsignedDecimal('total', 12, 2)->default(0)->comment('订单金额');
$table->unsignedDecimal('amount', 12, 2)->default(0)->comment('产生分红');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bouns_orders');
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBounsUserPervesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bouns_user_perves', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id')->comment('用户ID');
$table->timestamp('date')->nullable()->comment('分红时间');
$table->unsignedInteger('star')->nullable()->comment('当时星级');
$table->unsignedDecimal('old_perf', 12, 2)->default(0)->comment('累计业绩');
$table->unsignedDecimal('new_perf', 12, 2)->default(0)->comment('新增业绩');
$table->unsignedDecimal('price', 12, 6)->nullable()->comment('单价');
$table->unsignedDecimal('amount', 12, 2)->nullable()->comment('应得');
$table->boolean('status')->default(0)->comment('状态');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bouns_user_perves');
}
}

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();
}
}