/** * Add a pet to a user's PetBasket * @return boolean true on successful insertion or false otherwise */ public static function addToBasket() { $post = Core\Input::post(); if (isset($post['userId']) && isset($post['petId'])) { $basket = new Basket($post['userId'], array()); $res = $basket->addPet($post['petId']); $pet = Pet::constructById($post['petId']); $pet->loadImages(); if ($res) { return json_encode(array('userId' => $post['userId'], 'pet' => $pet->__toString())); } } return false; }