take() public method

Take the first or last {$limit} items.
public take ( integer $limit ) : static
$limit integer
return static
Example #1
0
 protected function summarizeTopBrowsers(Collection $topBrowsers, int $maxResults) : Collection
 {
     return $topBrowsers->take($maxResults - 1)->push(['browser' => 'Others', 'sessions' => $topBrowsers->splice($maxResults - 1)->sum('sessions')]);
 }