Showing 10 of 2,055 results.

Laravel Artisan Generator Command: The make:migration Command

…eate a new database table while using the --table will generate a migration for modifying an existing table with the value set. The behavior of the --create option will take precedence if both options are supplied. The following examples...

Laravel 5 Collections: Removing Collection Elements With forget

The forget method removes an item from the collection based on given $key . The forget method returns a reference to the original collection, meaning it modifies the collection instance it was called on.1 public function forget ( 2 $ keys 3 ) ;The...

Calculating Averages Using Collections in Laravel

The avg method is a useful method for calculating the average of all items in the collection. The avg method defines an optional $key parameter, which can be used to specify what property of the collection should be averaged. If no key is...

Laravel Collection Public API: avg

avg($key = null) The avg method is a useful method for calculating the average of all items in the collection. The avg method defines an optional $key parameter, which can be used to specify what property of the collection should be averaged. If...

Laravel 5 Collections: Randomizing Element Order With shuffle

The shuffle method is used to rearrange the items of the array in a random distribution. The shuffle method will return a new collection and will not modify the original collection instance.1 public function shuffle ( 2 $ seed = null 3 ) ;The...

Laravel Collection Public API: forPage

forPage($page, $perPage) The forPage method is used to implement pagination over collections. The forPage defines two parameters: $page , which is used to tell the collection which "page" should be returned and $perPage , which is used to control...