feat(desfile): add entry reservation model
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Domains\Commerce\Catalog\Models;
|
||||
|
||||
use App\Shared\Attachable\Models\Attachment;
|
||||
use App\Domains\Ticketing\Desfile\Models\EntryReservation;
|
||||
use App\Domains\Ticketing\Event\Models\EventDate;
|
||||
use App\Domains\Ticketing\Ticket\Models\Ticket;
|
||||
use App\Shared\Attachable\Models\Attachment;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -74,6 +75,12 @@ class Variant extends Model
|
||||
return $this->hasMany(Ticket::class, 'source_variant_id');
|
||||
}
|
||||
|
||||
/** @return HasMany<EntryReservation, $this> */
|
||||
public function desfileEntryReservations(): HasMany
|
||||
{
|
||||
return $this->hasMany(EntryReservation::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Inventory, $this> */
|
||||
public function inventory(): BelongsTo
|
||||
{
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticketing\Desfile\Enums;
|
||||
|
||||
enum EntryReservationPaymentType: string
|
||||
{
|
||||
case Free = 'sin_cargo';
|
||||
case Other = 'otro_metodo';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Free => 'Sin cargo',
|
||||
self::Other => 'Otro método',
|
||||
};
|
||||
}
|
||||
|
||||
/** @return list<array{value: string, label: string}> */
|
||||
public static function options(): array
|
||||
{
|
||||
return array_map(
|
||||
fn (self $type): array => [
|
||||
'value' => $type->value,
|
||||
'label' => $type->label(),
|
||||
],
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
36
app/Domains/Ticketing/Desfile/Models/EntryReservation.php
Normal file
36
app/Domains/Ticketing/Desfile/Models/EntryReservation.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticketing\Desfile\Models;
|
||||
|
||||
use App\Domains\Commerce\Catalog\Models\Variant;
|
||||
use App\Domains\Ticketing\Desfile\Enums\EntryReservationPaymentType;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable([
|
||||
'variant_id',
|
||||
'fecha_reserva',
|
||||
'importe',
|
||||
'tipo_pago',
|
||||
])]
|
||||
class EntryReservation extends Model
|
||||
{
|
||||
protected $table = 'desfile_entry_reservations';
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'variant_id' => 'integer',
|
||||
'fecha_reserva' => 'datetime',
|
||||
'importe' => 'decimal:2',
|
||||
'tipo_pago' => EntryReservationPaymentType::class,
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Variant, $this> */
|
||||
public function variant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Variant::class)->withTrashed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user