My simplified Model relationships:
User (id, email) → Timeline (id, user_id) → Activity (id, timeline_id) → Trackpoint(id, activity_id)
Q1: How do I get Trackpoints for a specific user and date range?
Q2: How do I get the Timeline for a certain Trackpoint?
I currently use a DB query for Q1, but was hoping there was a more... Eloquent way.
$trackpoints = DB::table('trackpoints')
->join('activities', 'activities.id', '=', 'trackpoints.activity_id')
->join('timelines', 'timelines.id', '=', 'activities.timeline_id')
->where('timelines.user_id', 1)
->whereBetween('trackpoints.timestamp',['2019-12-13','2019-12-16'])
Or does that require e.g. https://github.com/staudenmeir/belongs-to-through ?