Showing 10 of 1,280 results.

Laravel Collection Public API: random

random($amount = 1) The random method will retrieve a random $amount of items from the collection. By default, the random method will return only one item, however a different $amount can be passed in to change the number of items returned. If the...

Laravel 5: Dispatching Queued Jobs With dispatch

The dispatch helper function can be used to push a new job onto the job queue (or dispatch the job). This function returns a new instance of \Illuminate\Foundation\Bus\PendingDispatch ; having access to this class instance will allow you to modify...

Laravel Collection Public API: sortBy

sortBy($callback, $options = SORT_REGULAR, $descending = false) The sortBy method is useful and versatile way to sort collections by some key, or by some value returned by a $callback . The $callback can either be a function that defines two...

Laravel Collection Public API: groupBy

groupBy($groupBy, $preserveKeys = false) The groupBy method is used to group a collection based on a given value, represented by the $groupBy parameter. An argument passed to $groupBy can be a simple string, representing the value that the...

Laravel Collection Public API: sort

sort(callable $callback = null) The sort method is used to sort the collection. If no $callback is provided, the collection will be sorted using a case-insensitive "natural order" algorithm. An optional $callback can be supplied to customize the...

Laravel Application Helper Function: factory

factory() The factory function is used to create Eloquent models, generally used when testing an application. The factory method can generally take one of four forms: 1 <?php 2 3 // Return an instance of the 'User' model. 4 $ user = factory ( '...

Laravel String Helper Function: words

The words helper method is similar to the limit function, but instead of limiting the number of characters returned, it limits the number of words returned. The signature for the words helper function is: words($value, $words = 100, $end = '...')...