Creation and editing of events

This commit is contained in:
2026-02-16 21:59:21 +01:00
parent 2b458eccd7
commit fcf41c5d13
61 changed files with 3002 additions and 380 deletions

34
app/Casts/AmountCast.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Casts;
use App\ValueObjects\Amount;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
class AmountCast implements CastsAttributes
{
public function get(Model $model, string $key, mixed $value, array $attributes): ?Amount
{
if ($value === null) {
return null;
}
return new Amount((float) $value, 'Euro');
}
public function set(Model $model, string $key, mixed $value, array $attributes): ?float
{
if ($value === null) {
return null;
}
if ($value instanceof Amount) {
return $value->getAmount();
}
return (float) $value;
}
}