Eloquent filter on pivot table created_at
问题 I want to filter the contents of two tables which have an Eloquent belongsToMany() to each other based on the created_at column in the pivot table that joins them. Based on this SO question I came up with the following: $data = ModelA::with(['ModelB' => function ($q) { $q->wherePivot('test', '=', 1); }])->get(); Here I'm using a simple test column to check if it's working, this should be 'created_at'. What happens though is that I get all the instances of ModelA with the ModelB information if