Refactor Prop model to use enum for data types; remove PropDataType model and update related requests and migrations
This commit is contained in:
26
app/Domains/Prop/Support/PropDataType.php
Normal file
26
app/Domains/Prop/Support/PropDataType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Prop\Support;
|
||||
|
||||
enum PropDataType: string
|
||||
{
|
||||
case String = 'string';
|
||||
case Integer = 'integer';
|
||||
case Decimal = 'decimal';
|
||||
case Boolean = 'boolean';
|
||||
case Date = 'date';
|
||||
case DateTime = 'datetime';
|
||||
case Json = 'json';
|
||||
case Select = 'select';
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
return array_map(
|
||||
static fn (self $type): string => $type->value,
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,9 @@ class PropableModels
|
||||
|
||||
return $modelClass;
|
||||
}
|
||||
|
||||
public static function aliasFor(string $modelClass): ?string
|
||||
{
|
||||
return array_search($modelClass, static::map(), true) ?: null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user