Signature | Laravel 5 Collections: Grouping Collection Elements With groupBy
1 public function groupBy ( 2 $ groupBy , 3 $ preserveKeys = false 4 ) ;
Showing 10 of 1,280 results.
1 public function groupBy ( 2 $ groupBy , 3 $ preserveKeys = false 4 ) ;
The following collection will be used throughout this section when demonstrating the groupBy method: 1 use Illuminate \ Support \ Collection ; 2 3 // Create a new collection instance. 4 $ collection = new Collection ( [ 5 [ 6 ' genus ' => ' Canis...
By default, the groupBy method will not preserve the keys in the underlying collection when grouping items. The following code sample shows how the groupBy method groups by default, and the output: 1 use Illuminate \ Support \ Collection ; 2 3 4...
The signature of the collapse method is: 1 public static function collapse ( 2 $ array 3 ) ;
The examples that follow will use integers in all arrays. Assuming the following array and example: 1 use \ Illuminate \ Support \ Arr ; 2 3 $ testArray = [ 4 [ 5 1 , 2 , 3 , 4 6 ] , 7 [ 8 5 , 6 , 7 , 8 , 9 ] 10 ] ; 11 12 $ collapsedArray = Arr ::...
The collapse method will also work on collections. There is no special syntax required to use collections with the collapse method: 1 use \ Illuminate \ Support \ Arr ; 2 use \ Illuminate \ Support \ Collection ; 3 4 $ testArray = [ 5 new...
The array_collapse function is a shortcut to calling Arr::collapse . This function is declared in the global namespace.
As stated earlier, tasks are added to the App\Console\Kernel class via the schedule method. The schedule method provides access to the shared Schedule instance (provided by the Illuminate\Foundation\Console\Kernel base class): 1 <?php 2 3...
It is possible to schedule a function to execute at a given interval using the schedule's call method: 1 <?php 2 3 // ... 4 5 protected function schedule ( Schedule $ schedule ) 6 { 7 $ schedule -> call ( function ( ) { 8 // Some task to execute...
By default all the scheduled tasks and events will not run when the application is in maintenance mode. This can be changed by calling the evenInMaintenanceMode() method: 1 <?php 2 3 // ... 4 5 6 protected function schedule ( Schedule $ schedule )...