所以我有一个变量和一个记录集:
$firstRecordID = 1;
$records = Recordset::all();
我想过滤记录集:
$filteredRecords = $records->find(function($record) use ($firstRecordID){
return ($record->id == $firstRecordID);
});
在这个例子中,假设记录 id 是一个主键,只有一行会被返回,但是,我认为过滤器会继续运行。
我的问题是,如何在满足特定条件后强制过滤器停止?
编辑:我将添加另一个更复杂的示例:
$filteredRecords = $records->find(function($record) use ($lastRecordID){
$conditions == $records->conditions;
// in here I would find some value
// based on some other unknown record based on the $conditions
// if the value matches any of the $conditions return the row
// if the value matches a specified stop condition
// (which is defined by the user) stop retrieving rows.
});