It boils down to fetching items within 2 dates, so I would create a scope for the Item model that filters by created_at between a starting and an ending date.
You could then add some other methods to simplify its usage, like, if you want to get items that came between a given transaction and the next, it would be useful to get it with something like:
$items = Items::duringTransacion($transaction);
// or
$items = $transaction->itemsUntilNext();
Both of these would use a similar implementation. Here is an example of the latter:
class Transaction extends Model
{
// ...
public function itemsUntilNext()
{
// Fetch relevant dates
$startDate = $this->created_at;
$endDate = static::where('created_at', '>', $startDate)
->orderBy('created_at')
->first()
->pluck('created_at');
// Get items using Items::scopeCreatedWithin($start, $end)
return Item::createdWithin($startDate, $endDate)
->get();
}
}