Files
fotospiel-app/app/Models/Photo.php
Codex Agent 6290a3a448 Fix tenant event form package selector so it no longer renders empty-value options, handles loading/empty
states, and pulls data from the authenticated /api/v1/tenant/packages endpoint.
    (resources/js/admin/pages/EventFormPage.tsx, resources/js/admin/api.ts)
  - Harden tenant-admin auth flow: prevent PKCE state loss, scope out StrictMode double-processing, add SPA
    routes for /event-admin/login and /event-admin/logout, and tighten token/session clearing semantics (resources/js/admin/auth/{context,tokens}.tsx, resources/js/admin/pages/{AuthCallbackPage,LogoutPage}.tsx,
    resources/js/admin/router.tsx, routes/web.php)
2025-10-19 23:00:47 +02:00

74 lines
1.7 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Models\EventMediaAsset;
use Znck\Eloquent\Relations\BelongsToThrough as BelongsToThroughRelation;
use Znck\Eloquent\Traits\BelongsToThrough;
class Photo extends Model
{
use HasFactory;
use BelongsToThrough;
protected $table = 'photos';
protected $guarded = [];
protected $casts = [
'is_featured' => 'boolean',
'metadata' => 'array',
'security_meta' => 'array',
'security_scanned_at' => 'datetime',
];
protected $attributes = [
'security_scan_status' => 'pending',
];
public function mediaAsset(): BelongsTo
{
return $this->belongsTo(EventMediaAsset::class, 'media_asset_id');
}
public function getImagePathAttribute(): ?string
{
return $this->file_path;
}
public function setImagePathAttribute(string $value): void
{
$this->attributes['file_path'] = $value;
}
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function emotion(): BelongsTo
{
return $this->belongsTo(Emotion::class);
}
public function task(): BelongsTo
{
return $this->belongsTo(Task::class);
}
public function likes(): HasMany
{
return $this->hasMany(PhotoLike::class);
}
public function tenant(): BelongsToThroughRelation
{
return $this->belongsToThrough(
Tenant::class,
Event::class
);
}
}