<?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('tills', function (Blueprint $table) {
            $table->id();
            $table->string('identifier', 20)->unique(); // TILL-NNNNN
            $table->string('name', 100);
            $table->foreignId('branch_id')->nullable()->constrained('warehouses')->nullOnDelete();
            $table->string('location', 255)->nullable();
            $table->string('invoice_prefix', 10)->nullable();
            $table->enum('type', ['sales_device', 'till_machine']);
            $table->boolean('is_active')->default(true);
            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
            $table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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