feat: enums

This commit is contained in:
Leon 2025-12-19 11:48:11 +01:00
parent 101181893e
commit 11c1c850c9
6 changed files with 91 additions and 2 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace App\Enums;
enum HuntDifficulty: string
{
case EASY = 'easy';
case MEDIUM = 'medium';
case HARD = 'hard';
public static function values(): array
{
return array_column(self::cases(), 'value');
}
}

15
app/Enums/HuntStatus.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Enums;
enum HuntStatus : string
{
case DRAFT = 'draft';
case PUBLISHED = 'published';
case ARCHIVED = 'archived';
public static function values(): array
{
return array_column(self::cases(), 'value');
}
}

View File

@ -36,5 +36,7 @@ class Hunts extends Model
'latitude' => 'float',
'longitude' => 'float',
'estimated_duration_min' => 'integer',
'status' => HuntStatus::class,
'difficulty' => HuntDifficulty::class,
];
}

View File

@ -55,8 +55,6 @@ services:
environment:
PMA_HOST: mysql
PMA_PORT: 3306
PMA_USER: "${DB_USERNAME}"
PMA_PASSWORD: "${DB_PASSWORD}"
networks:
- sail
depends_on:

View File

@ -0,0 +1,31 @@
<?php
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::table('hunts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('xp')->default(0);
$table->string('status')->default('draft');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('hunts', function (Blueprint $table) {
//
});
}
};

View File

@ -0,0 +1,28 @@
<?php
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::table('users', function (Blueprint $table) {
$table->string('role')->default('user');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};