feat: Implement public event and photo API
This commit is contained in:
@@ -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...
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user