Esempio n. 1
0
 /**
  * Create a new experience
  * @param String $objExperience: a json object of SharcExperience                  
  */
 public static function addNewExperience($objExperience)
 {
     $response = array();
     try {
         $rs = SharcExperience::where('name', $objExperience['name'])->get();
         //if ($rs->count() == 0){ //Not exists -> add a new experience
         if (0 == 0) {
             //Temporal: allow duplicated name as support offline -> cann't always check this -> edit later
             $experience = SharcExperience::create(array('id' => $objExperience['id'], 'name' => $objExperience['name'], 'description' => $objExperience['description'], 'createdDate' => date('Y-m-d'), 'lastPublishedDate' => date('Y-m-d'), 'designerId' => $objExperience['designerId'], 'isPublished' => $objExperience['isPublished'], 'moderationMode' => $objExperience['moderationMode'], 'latLng' => $objExperience['latLng'], 'summary' => $objExperience['summary'], 'snapshotPath' => $objExperience['snapshotPath'], 'thumbnailPath' => $objExperience['thumbnailPath'], 'size' => $objExperience['size'], 'theme' => $objExperience['theme']));
             $result = $experience->save();
             if ($result) {
                 //= 1 success
                 $response["status"] = SUCCESS;
                 $response["data"] = $experience->toArray();
             } else {
                 //error
                 $response["status"] = ERROR;
                 $response["data"] = INTERNAL_SERVER_ERROR;
             }
         } else {
             //fail AS exists
             $response["status"] = FAILED;
             $response["data"] = EXPERIENCE_EXIST;
         }
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }