feat(event): add address relationship and migration for event locations

This commit is contained in:
2026-09-30 09:26:19 -03:00
parent 1633c30a22
commit cfa7acabe0
6 changed files with 313 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Domains\Ticketing\Event\Models;
use App\Domains\Commerce\Catalog\Models\CatalogItem;
use App\Domains\Core\Address\Models\Address;
use App\Domains\Core\Client\Models\Client;
use App\Domains\Core\Tenant\Models\SocialMedia;
use App\Domains\Core\Tenant\Models\Tenant;
@@ -15,14 +16,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['client_id', 'tenant_code', 'slug', 'event_category_id', 'title', 'subtitle', 'description', 'location', 'exact_location', 'date_text', 'published_at', 'attachment_id'])]
#[Fillable(['client_id', 'tenant_code', 'slug', 'event_category_id', 'title', 'subtitle', 'description', 'address_id', 'location', 'exact_location', 'date_text', 'published_at', 'attachment_id'])]
class Event extends Model
{
use HasFactory;
protected function casts(): array
{
return ['client_id' => 'integer', 'published_at' => 'datetime', 'exact_location' => 'array'];
return ['client_id' => 'integer', 'address_id' => 'integer', 'published_at' => 'datetime', 'exact_location' => 'array'];
}
/** @return BelongsTo<Tenant, $this> */
@@ -37,6 +38,12 @@ class Event extends Model
return $this->belongsTo(Client::class);
}
/** @return BelongsTo<Address, $this> */
public function address(): BelongsTo
{
return $this->belongsTo(Address::class);
}
public function effectiveClient(): Client
{
return $this->client ?? $this->tenant->client;