admin_users 테이블생성

This commit is contained in:
sungro815 2026-01-07 16:26:16 +09:00
parent 8cde679a89
commit 625ebc9a7c
2 changed files with 100 additions and 0 deletions

36
app/Models/AdminUser.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class AdminUser extends Authenticatable
{
use Notifiable;
protected $table = 'admin_users';
protected $fillable = [
'email','password',
'full_name','nickname','phone',
'role','status',
'is_consult_available','consult_types',
'totp_secret','totp_enabled','totp_confirmed_at',
'last_login_at','last_login_ip',
];
protected $hidden = [
'password',
'remember_token',
'totp_secret',
];
protected $casts = [
'is_consult_available' => 'boolean',
'consult_types' => 'array', // ✅ JSON <-> array 자동 변환
'totp_enabled' => 'boolean',
'totp_confirmed_at' => 'datetime',
'last_login_at' => 'datetime',
];
}

View File

@ -0,0 +1,64 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('admin_users', function (Blueprint $table) {
$table->id();
// 로그인
$table->string('email')->unique();
$table->string('password');
// 관리자 기본 정보
$table->string('full_name', 50); // 관리자 성명
$table->string('nickname', 30)->unique(); // 관리자 닉네임
$table->string('phone', 20)->nullable()->unique(); // 전화번호(선택)
/**
* 관리자 등급(role)
* : super(최고관리자), admin(일반관리자), cs(상담전용)...
*/
$table->string('role', 20)->default('admin')->index();
/**
* 관리자 상태(status)
* : active(정상), blocked(접근금지), suspended(일시정지)
*/
$table->string('status', 20)->default('active')->index();
// 상담 가능 여부
$table->boolean('is_consult_available')->default(false)->index();
/**
* 상담 종류(JSON)
* : ["signup","login","payment","giftcard","event"]
* - pivot 테이블 쓰고 단일테이블로 운영하려면 이게 제일 깔끔함
*/
$table->json('consult_types')->nullable();
// Google OTP (TOTP)
// "code(6자리)" 저장 X → "secret(시드)" 저장 O (암호화 저장 권장)
$table->text('totp_secret')->nullable();
$table->boolean('totp_enabled')->default(false)->index();
$table->timestamp('totp_confirmed_at')->nullable();
// 로그인 흔적 (보안/감사)
$table->timestamp('last_login_at')->nullable();
$table->string('last_login_ip', 45)->nullable();
// remember me
$table->rememberToken();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('admin_users');
}
};