feat(event): restore event model and migrate tenant event data
This commit is contained in:
48
app/Domains/Ticketing/Event/Models/Event.php
Normal file
48
app/Domains/Ticketing/Event/Models/Event.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticketing\Event\Models;
|
||||
|
||||
use App\Domains\Core\Tenant\Models\SocialMedia;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['tenant_code', 'title', 'subtitle', 'description', 'location', 'date_text', 'published_at'])]
|
||||
class Event extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['published_at' => 'datetime'];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Tenant, $this> */
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant_code', 'codigo');
|
||||
}
|
||||
|
||||
/** @return HasMany<EventDate, $this> */
|
||||
public function dates(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventDate::class)->orderBy('date')->orderBy('time_start');
|
||||
}
|
||||
|
||||
/** @return BelongsToMany<SocialMedia, $this> */
|
||||
public function socialMedia(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
SocialMedia::class,
|
||||
'event_social_media',
|
||||
'event_id',
|
||||
'social_media_code',
|
||||
'id',
|
||||
'code',
|
||||
)->withPivot(['url', 'orden'])->withTimestamps()->orderByPivot('orden');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user