public static function createNewWinery($input) { $winery = new Winery(); $error_code = ApiResponse::OK; if (!empty($input['brand_name'])) { $winery->brand_name = $input['brand_name']; if (!empty($input['country_id'])) { if (Country::where('id', $input['country_id'])->first()) { $winery->country_id = $input['country_id']; } else { $winery->country_id = null; } } if (!empty($input['region'])) { $winery->region = $input['region']; } if (!empty($input['description'])) { $winery->description = $input['description']; } // Validation and Filtering is sorely needed!! // Seriously, I'm a bad person for leaving that out. $winery->save(); $data = $winery->toArray(); } else { $error_code = ApiResponse::MISSING_PARAMS; $data = $input; } return array("code" => $error_code, "data" => $data); }
public function setUpData() { $user = new User(); $user->email = '*****@*****.**'; $user->password = '******'; $user->fb_id = '123456'; $user->save(); $this->_user_id = User::where('email', '*****@*****.**')->first()->user_id; $login = new Login(); $login->id = 1; $login->user_id = $this->_user_id; $login->session_id = '3f9a362bb40714f77cadfd9f5b9d801b'; $login->expired_at = '2019-07-30'; $login->save(); $this->_session = '3f9a362bb40714f77cadfd9f5b9d801b'; $this->_user_id = Login::where('session_id', $this->_session)->first()->user_id; $winery = new Winery(); $winery->id = 1; $winery->brand_name = 'Winery 1'; $winery->country_id = '1'; $winery->region = 'Abkhazia'; $winery->save(); $wine = new Wine(); $wine->wine_id = 1; $wine->name = 'Wine_1'; $wine->rakuten_id = 'rakuten_drinkshop_10508227'; $wine->original_name = "this is wine_1"; $wine->original_name_2 = "wine_1"; $wine->winery_id = 1; $wine->year = '2009'; $wine->wine_unique_id = '1_2009'; $wine->average_price = "2200.00"; $wine->average_rate = "3.5"; $wine->rate_count = "3"; $wine->save(); $this->session(array('user_id' => $this->_user_id)); }