/** * Create a response model object from a completed command. * * @param OperationCommand $command That serialized the request * @return \Illuminate\Support\Collection */ public static function fromCommand(OperationCommand $command) { // Initialize the collection $collection = new self($command->getResponse()->json()); // Set the Usergrid API client on the collection $collection->setApiClient($command->getClient()->getApiClient()); // Return the collection return $collection; }
/** * Constructor * * @param OperationCommand $command */ public function __construct(OperationCommand $command) { $this->setClient($command->getClient()); $this->setCommandName($command->getName()); $data = $command->getResponse()->json(); foreach ($data as $key => $value) { $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); if (method_exists($this, $setter)) { $this->{$setter}($value); } } }