Example #1
0
$books = Usergrid::application()->EntityGet(['collection' => 'books', 'limit' => 25]);
// get result count just call the Illuminate\Support\Collection  count method
var_dump($books->entities->count());
// As responses are model object you can treat them like a assoc arrays
var_dump($books->entities[0]['uuid']);
// if you like a more object orientated way then use the Collection Class methods
// get all uuid
var_dump($books->entities->fetch('uuid'));
//get first uuid
var_dump($books->entities->fetch('uuid')->first());
// get first item in collection -- this is the first item in my response php collection not the Usergrid Collection (table).
var_dump($books->entities->first());
// get last item in collection -- this is the last item in my response php collection not the Usergrid Collection (table).
var_dump($books->entities->last());
// convert created date to string
var_dump(Date::convert($books->entities->fetch('created')->first()));
// Illuminate\Support\Collection class support all advanced collection methods
// pop last item off collection
$book = $books->entities->pop();
// Converting methods
$json_ = $books->entities->toJson();
//Convert the object into something JSON serializable.
$books->entities->jsonSerialize();
// Get an iterator for the items in collection
$iterator = $books->entities->getIterator();
//Get a CachingIterator instance
$caching_iterator = $books->entities->getCachingIterator();
/// Here are some more Methods that you can call on your responses .. To get the most out of this SDK please look at the Illuminate\Support\Collection class
/// which is the supper class of Apache/Usergrid/Api/Models/BaseCollection class
/**
   $books->unique();
Example #2
0
 /** @test */
 public function it_can_convert_dates()
 {
     $this->assertEquals('Tue, Oct 14, 2014 3:55 AM', Date::convert(1413258923819));
 }