Skip to content

Commit

Permalink
2.2 Platformer length fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1DEA committed Dec 27, 2023
1 parent 4396d41 commit 1570ca9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Actions/Hydrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function level(int $id, bool $abort = true): ?Level
];

$lengths = [
'plat' => -1,
'tiny' => 0,
'short' => 1,
'medium' => 2,
Expand Down
54 changes: 54 additions & 0 deletions app/Doctrine/TinyInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Doctrine;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

/**
* @author dmitry-kulikov
* @see https://github.com/laravel/framework/issues/8840
*/
class TinyInteger extends Type
{
/**
* The name of the custom type.
*/
public const NAME = 'tinyinteger';

/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return $value === null ? null : (int)$value;
}

/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
$unsigned = !empty($column['unsigned']) ? ' UNSIGNED' : '';
$autoincrement = !empty($column['autoincrement']) ? ' AUTO_INCREMENT' : '';

return 'TINYINT' . $unsigned . $autoincrement;
}

/**
* {@inheritdoc}
*/
public function getName(): string
{
return static::NAME;
}

/**
* {@inheritdoc}
*/
public function getBindingType(): int
{
return ParameterType::INTEGER;
}
}
19 changes: 19 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Doctrine\TinyInteger;
use Illuminate\Support\Str;

return [
Expand All @@ -17,6 +18,24 @@

'default' => env('DB_CONNECTION', 'mysql'),

/*
|--------------------------------------------------------------------------
| Fucking Hell
|--------------------------------------------------------------------------
|
| There is no god
|
| https://github.com/laravel/framework/issues/8840
|
*/

'dbal' => [
'types' => [
TinyInteger::NAME => TinyInteger::class,
],
],


/*
|--------------------------------------------------------------------------
| Database Connections
Expand Down
Original file line number Diff line number Diff line change
@@ -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('levels', function (Blueprint $table) {
// FUCK: Kill Me Please https://github.com/laravel/framework/issues/8840
$table->tinyInteger('length')->nullable()->change();
$table->tinyInteger('epic')->nullable()->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('levels', function (Blueprint $table) {
$table->unsignedTinyInteger('length')->nullable()->change();
$table->boolean('epic')->nullable()->change();
});
}
};

0 comments on commit 1570ca9

Please sign in to comment.