cafeg/database/migrations/0001_01_01_000000_create_users_table.php
2025-01-20 16:42:05 +08:00

64 lines
2.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->nullable()->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('line_id')->nullable()->comment('line user_id');
$table->string('phone')->nullable()->comment('手機電話');
// $table->string('role')->comment('admin,agent');
$table->string('password');
$table->string('avatar')->nullable(); // 頭像
$table->boolean('can_login')->default(true); // 是否可以登入
$table->rememberToken();
$table->softDeletes();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->id();
$table->string('name')->default('客戶')->nullable(); // 使用者名稱
$table->string('email')->nullable()->unique(); // 電子郵件
$table->string('password'); // 密碼
$table->string('avatar')->nullable(); // 頭像
$table->string('phone')->nullable(); // 電話
$table->string('line_id')->nullable()->unique(); // Line ID
$table->string('facebook_id')->nullable()->unique(); // Facebook ID
$table->string('google_id')->nullable()->unique(); // Google ID
$table->integer('level')->default(1)->comment('會員等級 一般,1.系統管理員,2工程師'); // 會員等級
$table->string('reset_token')->nullable(); // 密碼重置 Token
$table->timestamp('email_verified_at')->nullable(); // 電子郵件驗證時間
$table->rememberToken(); // 記住登入 Token
$table->timestamps(); // 建立與更新時間
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};