1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 08:04:05 +02:00

feat(element-queries): update methods first() next() last() #436

This commit is contained in:
Awilum
2020-07-15 23:39:28 +03:00
parent 8c779ad682
commit b496d47d34

View File

@@ -298,7 +298,17 @@ class Collection
*/
public function last() : array
{
return array_undot($this->matchCollection()->last());
// Match collection
$collection = $this->collection->matching($this->criteria);
// Restore error_reporting
error_reporting($this->errorReporting);
// Gets first matching result
$results = $collection->last();
// Return first matching result
return is_array ($results) ? array_undot($results) : $results;
}
/**
@@ -312,7 +322,17 @@ class Collection
*/
public function next() : array
{
return array_undot($this->matchCollection()->next());
// Match collection
$collection = $this->collection->matching($this->criteria);
// Restore error_reporting
error_reporting($this->errorReporting);
// Gets first matching result
$results = $collection->next();
// Return first matching result
return is_array ($results) ? array_undot($results) : $results;
}
/**
@@ -361,8 +381,11 @@ class Collection
// Restore error_reporting
error_reporting($this->errorReporting);
// Gets first matching result
$results = $collection->first();
// Return first matching result
return $collection->first();
return is_array ($results) ? array_undot($results) : $results;
}
/**