<?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('staff_users', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->string('name');
            $table->string('role')->default('cashier'); // cashier | manager | admin
            $table->string('avatar')->nullable();
            $table->boolean('is_active')->default(true);
            $table->json('permissions')->nullable(); // custom permission overrides
            $table->timestamps();
            // No PIN stored server-side — PINs stay on-device for security
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('staff_users');
    }
};
