It does have this functionality.
class Event ...
{
public function creator()
{
return $this->belongsTo('User'); // assuming user_id
}
public function attendees()
{
return $this->belongsToMany('User'); // assumes a pivot table event_user
}
}
$event = Event::with('creator', 'attendees')->find($id);
$event->creator->name; // Bob
$event->attendees->count(); // 4
Also Event is an existing class already in Laravel and is Aliased. So I imagine this was changed already in your app.
'Event' => 'Illuminate\Support\Facades\Event',
Thanks, this is exactly what I wanted, and yes, i wasnt using event, my actual use case is a lot more abstract, i picked this example because its easier to understand
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community