重新设计表结构

This commit is contained in:
WispX
2021-12-11 20:06:04 +08:00
parent 874a554829
commit 8853cac38d
9 changed files with 243 additions and 42 deletions

View File

@@ -31,6 +31,11 @@ class User extends Authenticatable
protected $hidden = [
'password',
'remember_token',
'registered_ip',
'configs',
'status',
'group_id',
'is_adminer',
];
/**

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('groups', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->id();
$table->string('name', 64)->comment('角色组名称');
$table->boolean('is_default')->default(false)->comment('是否默认');
$table->json('configs')->comment('组配置');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('groups');
}
}

View File

@@ -14,12 +14,24 @@ class CreateUsersTable extends Migration
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->foreignId('group_id')->nullable()->comment('角色组')->constrained('groups')->onDelete('set null');
$table->string('name')->comment('姓名');
$table->string('email')->unique()->comment('邮箱');
$table->string('password')->comment('密码');
$table->rememberToken();
$table->boolean('is_adminer')->default(false)->comment('是否为管理员');
$table->decimal('capacity', 20)->default(0)->comment('总容量(kb)');
$table->json('configs')->comment('配置');
$table->unsignedBigInteger('image_num')->default(0)->comment('图片数量');
$table->unsignedBigInteger('album_num')->default(0)->comment('相册数量');
$table->string('registered_ip')->default('')->comment('注册IP');
$table->enum('status', ['normal', 'frozen'])->default('normal');
$table->timestamp('email_verified_at')->nullable();
$table->timestamps();
});
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateStrategiesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('strategies', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->id();
$table->foreignId('group_id')->comment('角色组')->constrained('groups')->onDelete('cascade');
$table->enum('key', ['local'])->default('local');
$table->string('name', 64)->comment('策略名称');
$table->string('intro', 255)->default('')->comment('简介');
$table->json('configs')->comment('策略配置');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('strategies');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAlbumsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('albums', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->id();
$table->foreignId('user_id')->comment('用户')->constrained('users')->onDelete('cascade');
$table->string('name', 64)->comment('名称');
$table->string('intro')->default('')->comment('简介');
$table->unsignedBigInteger('image_num')->default(0)->comment('图片数量');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('albums');
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->id();
$table->foreignId('user_id')->nullable()->comment('用户')->constrained('users')->onDelete('set null');
$table->foreignId('album_id')->nullable()->comment('相册')->constrained('albums')->onDelete('set null');
$table->foreignId('strategy_id')->nullable()->comment('策略')->constrained('strategies')->onDelete('set null');
$table->string('path')->comment('保存路径');
$table->string('name')->comment('保存路径');
$table->string('origin_name')->default('')->comment('原始名称');
$table->string('alias_name')->default('')->comment('别名');
$table->decimal('size')->default(0)->comment('图片大小(kb)');
$table->string('mimetype', 32)->comment('文件类型');
$table->string('md5', 32)->comment('文件MD5');
$table->string('sha1')->comment('文件SHA1');
$table->boolean('is_unhealthy')->default(false)->comment('是否为不健康的');
$table->string('uploaded_ip')->default('')->comment('上传IP');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('images');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateConfigsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('configs', function (Blueprint $table) {
$table->string('name', 32)->comment('配置名')->unique();
$table->longText('value')->nullable()->comment('配置值');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('configs');
}
}

View File

@@ -22,7 +22,7 @@
<x-slot name="icon"><i class="fas fa-cloud-upload-alt text-blue-500"></i></x-slot>
<x-slot name="name">上传图片</x-slot>
</x-nav-link>
<x-nav-link :active="request()->routeIs('pictures')">
<x-nav-link :active="request()->routeIs('images')">
<x-slot name="icon"><i class="fas fa-images text-blue-500"></i></x-slot>
<x-slot name="name">图片</x-slot>
</x-nav-link>
@@ -56,7 +56,7 @@
<x-slot name="icon"><i class="fas fa-users-cog text-blue-500"></i></x-slot>
<x-slot name="name">用户管理</x-slot>
</x-nav-link>
<x-nav-link :active="request()->routeIs('admin/pictures')">
<x-nav-link :active="request()->routeIs('admin/images')">
<x-slot name="icon"><i class="fas fa-images text-blue-500"></i></x-slot>
<x-slot name="name">图片管理</x-slot>
</x-nav-link>

View File

@@ -10,55 +10,42 @@ use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\VerifyEmailController;
use Illuminate\Support\Facades\Route;
Route::get('/register', [RegisteredUserController::class, 'create'])
->middleware('guest')
->name('register');
Route::post('/register', [RegisteredUserController::class, 'store'])
->middleware('guest');
Route::get('/login', [AuthenticatedSessionController::class, 'create'])
->middleware('guest')
->name('login');
Route::post('/login', [AuthenticatedSessionController::class, 'store'])
->middleware('guest');
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
->middleware('guest')
->name('password.request');
Route::get('/register', [RegisteredUserController::class, 'create'])->middleware('guest')->name('register');
Route::post('/register', [RegisteredUserController::class, 'store'])->middleware('guest');
Route::get('/login', [AuthenticatedSessionController::class, 'create'])->middleware('guest')->name('login');
Route::post('/login', [AuthenticatedSessionController::class, 'store'])->middleware('guest');
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])->middleware('guest')
->name('password.request');
Route::post('/forgot-password', [PasswordResetLinkController::class, 'store'])
->middleware('guest')
->name('password.email');
->middleware('guest')
->name('password.email');
Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])
->middleware('guest')
->name('password.reset');
->middleware('guest')
->name('password.reset');
Route::post('/reset-password', [NewPasswordController::class, 'store'])
->middleware('guest')
->name('password.update');
->middleware('guest')
->name('password.update');
Route::get('/verify-email', [EmailVerificationPromptController::class, '__invoke'])
->middleware('auth')
->name('verification.notice');
->middleware('auth')
->name('verification.notice');
Route::get('/verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
->middleware(['auth', 'signed', 'throttle:6,1'])
->name('verification.verify');
->middleware(['auth', 'signed', 'throttle:6,1'])
->name('verification.verify');
Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
->middleware(['auth', 'throttle:6,1'])
->name('verification.send');
->middleware(['auth', 'throttle:6,1'])
->name('verification.send');
Route::get('/confirm-password', [ConfirmablePasswordController::class, 'show'])
->middleware('auth')
->name('password.confirm');
->middleware('auth')
->name('password.confirm');
Route::post('/confirm-password', [ConfirmablePasswordController::class, 'store'])
->middleware('auth');
->middleware('auth');
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
->middleware('auth')
->name('logout');
->middleware('auth')
->name('logout');