feat: Implement public event and photo API

This commit is contained in:
2025-09-09 21:22:20 +02:00
parent 8162af842f
commit 7743d91df6
2 changed files with 44 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
class Tenant extends Model
{
@@ -18,4 +19,16 @@ class Tenant extends Model
{
return $this->hasMany(Event::class);
}
public function photos(): HasManyThrough
{
return $this->hasManyThrough(
Photo::class,
Event::class,
'tenant_id', // Foreign key on events table...
'event_id', // Foreign key on photos table...
'id', // Local key on tenants table...
'id' // Local key on events table...
);
}
}