Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.
Anahkiasen edited this page Nov 24, 2012 · 12 revisions

Available methods

Informations about an object

Object::keys

Get the keys from an object

Object::values

Get the values from an object

Object::methods

List all methods of an object

Object::toJSON

Converts an object to JSON

Object::toJSON($article) // Returns {"name":"Article","author":"Maxime",...}

Object::group

Group an array by the results of a closure Instead of a closure a property name can be passed to group by it

Object::group($articles, function($value) {
  return $articles->created_at->format('Y'); // Returns articles sorted by creation year
})

Object::sort

Sort an array The second argument can be a closure returning what to sort by, or a property name The third argument is the direction (asc or desc)

Object::sort($articles, function($article) {
  return $article->name; // Returns article sorted by name
});
Object::sort($articles, 'author.name', 'desc') // Returns articles sorted by author name, DESC
Clone this wiki locally