Пример #1
0
 public static function createNewWinenote($input)
 {
     $user_id = Session::get('user_id');
     $winenote = new Winenote();
     $error_code = ApiResponse::OK;
     if (!empty($input['wine_unique_id']) && !empty($input['note'])) {
         $winenote->wine_unique_id = $input['wine_unique_id'];
         $winenote->note = $input['note'];
         $winenote->user_id = $user_id;
         // Validation and Filtering is sorely needed!!
         // Seriously, I'm a bad person for leaving that out.
         if (Wine::where('wine_unique_id', $winenote->wine_unique_id)->first()) {
             if (Winenote::where('wine_unique_id', $winenote->wine_unique_id)->where('user_id', $winenote->user_id)->first()) {
                 $error_code = ApiResponse::DUPLICATED_WINE_NOTE_ADD;
                 $data = ApiResponse::getErrorContent(ApiResponse::DUPLICATED_WINE_NOTE_ADD);
             } else {
                 $winenote->save();
                 $data = $winenote;
             }
         } else {
             $error_code = ApiResponse::UNAVAILABLE_WINE;
             $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_WINE);
         }
     } else {
         $error_code = ApiResponse::MISSING_PARAMS;
         $data = $input;
     }
     return array("code" => $error_code, "data" => $data);
 }
Пример #2
0
 public function setUp()
 {
     parent::setUp();
     $this->setUpData();
     $this->setUpRating();
     $winenote = new Winenote();
     $winenote->id = 1;
     $winenote->user_id = $this->_user_id;
     $winenote->wine_unique_id = '1_2009';
     $winenote->note = "this is note 1";
     $winenote->save();
 }
Пример #3
0
 public function setUp()
 {
     parent::setUp();
     $this->setUpData();
     $wine_note = new Winenote();
     $wine_note->wine_unique_id = "1_2009";
     $wine_note->user_id = $this->_user_id;
     $wine_note->note = "this is note test";
     $wine_note->save();
     $follow = new Follow();
     $follow->from_id = $this->_user_id;
     $follow->to_id = "3620a42d-fcbb-45eb-b3a5-36cada1b77b7";
     $follow->save();
 }
Пример #4
0
 public function setUpWineNote()
 {
     $winenote = new Winenote();
     $winenote->wine_unique_id = '1_2009';
     $winenote->note = 'this is note test';
     $winenote->user_id = $this->_user_id;
     $winenote->save();
 }