49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
use App\Enums\ItemType;
|
||
|
|
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('items', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->string('name', 100);
|
||
|
|
$table->string('slug', 100)->unique();
|
||
|
|
$table->text('description')->nullable();
|
||
|
|
$table->enum('type', ItemType::values());
|
||
|
|
$table->unsignedInteger('value')->default(0);
|
||
|
|
$table->unsignedInteger('buy_price')->nullable()->default(null);
|
||
|
|
$table->unsignedInteger('sell_price')->nullable()->default(null);
|
||
|
|
$table->unsignedInteger('requires_level')->nullable()->default(null);
|
||
|
|
$table->integer('attack_bonus')->default(0);
|
||
|
|
$table->integer('defense_bonus')->default(0);
|
||
|
|
$table->integer('health_bonus')->default(0);
|
||
|
|
$table->integer('energy_bonus')->default(0);
|
||
|
|
$table->boolean('is_tradeable')->default(true);
|
||
|
|
$table->boolean('is_usable')->default(false);
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
// Indexes
|
||
|
|
$table->index('slug');
|
||
|
|
$table->index('type');
|
||
|
|
$table->index('requires_level');
|
||
|
|
$table->index('buy_price');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reverse the migrations.
|
||
|
|
*/
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('items');
|
||
|
|
}
|
||
|
|
};
|