<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('prize_categories', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->boolean('status')->default(1);
            $table->timestamps();
        });

        Schema::create('prizes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('prize_category_id')->nullable()->constrained('prize_categories');
            $table->string('prize');
            $table->string('url_slug');
            $table->integer('total_count');
            $table->integer('drawn_count')->default(0);
            $table->boolean('status')->default(1);
            $table->timestamps();
        });

        Schema::create('prize_weeks', function (Blueprint $table) {
            $table->id();
            $table->string('prize_week');
            $table->date('prize_date');
            $table->boolean('status')->default(1);
            $table->timestamps();
        });

        //  Insert admin user
        DB::table('prize_weeks')->insert(
            array(
                'prize_week' => "prize_week",
                'prize_date'=>now(),
            )
        );
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('prizes');
    }
};
