Counting Models related through manyToMany only if a pivot attribute null - Laravel
问题 I am elaborating code acquired here ManyToMany relation - how update attribute in pivot table what I want: I want to get a collection of Activities related to any weekly Routine . The pivot table's atribute done_at tells me when any activity (task) was completed. I can list and later ->count() activities related to parent model in manyToMany relation: public function activities() { return $this->belongsToMany('App\Models\Activity', 'activity_routine', 'routine_id', 'activity_id')->withPivot(