コード例 #1
0
 public function searchLogDestroy($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     Search::find($id)->delete();
     return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($blackId)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     BlackList::where('user_id', $input['user_id'])->where('black_id', $blackId)->delete();
     return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #3
0
 public static function commonUploadImage($input, $path, $type = null)
 {
     $data = null;
     $sessionId = Common::checkSessionLogin($input);
     if (isset($input['image_url'])) {
         foreach ($input['image_url'] as $key => $value) {
             $filename[$key] = $value->getClientOriginalName();
             $filename[$key] = changeFileNameImage($filename[$key]);
             $filename[$key] = $key . $filename[$key];
             $pathUpload = public_path() . $path . '/' . $input['user_id'];
             $uploadSuccess = $value->move($pathUpload, $filename[$key]);
             if ($key == 0) {
                 if ($type == 1) {
                     $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->save();
                 } else {
                     $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->resize(USER_AVATAR_WIDTH, USER_AVATAR_HEIGHT)->save();
                 }
             } else {
                 $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->save();
             }
             $data[$key] = ['image_url' => $filename[$key]];
         }
         return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId, $data);
     }
     throw new Prototype\Exceptions\UploadErrorException();
 }
コード例 #4
0
 /**
  *
  * Param: productId
  *
  * @return Response
  */
 public function post($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $inputFeedback = ['product_id' => $id, 'user_id' => $input['user_id'], 'message' => $input['message'], 'status' => ACTIVE];
     Feedback::create($inputFeedback)->id;
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #5
0
 public function block($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $checkInput = BlackList::where('user_id', $input['user_id'])->where('black_id', $id)->get();
     if (!empty($checkInput)) {
         BlackList::create(['user_id' => $input['user_id'], 'black_id' => $id, 'kind' => 1]);
     }
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $favorite = Favorite::where('model_name', 'Product')->where('model_id', $id)->where('follow_id', $input['user_id'])->where('type_favorite', TYPE_FAVORITE_SAVE)->first();
     if (isset($favorite)) {
         $favorite->delete();
     }
     return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #7
0
 public function action($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $check = CommonFavorite::checkFavoriteLike('Category', $id, TYPE_FAVORITE_CATE, $input['user_id']);
     if ($check) {
         Favorite::where('model_name', 'Category')->where('model_id', $id)->where('follow_id', $input['user_id'])->where('type_favorite', TYPE_FAVORITE_CATE)->delete();
     } else {
         Favorite::create(['model_name' => 'Category', 'model_id' => $id, 'follow_id' => $input['user_id'], 'type_favorite' => TYPE_FAVORITE_CATE]);
     }
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #8
0
 public function index()
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $user = User::find($input['user_id']);
     //tao code phone
     $codePhone = generateRandomString(CODEPHONE);
     //luu code phone -> db
     $user->update(['code_phone' => $codePhone]);
     //gui code cho dau so
     //active user
     $user->update(['status' => ACTIVE]);
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #9
0
 public function action($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $favorite = Favorite::where('model_name', 'User')->where('model_id', $id)->where('follow_id', $input['user_id'])->where('type_favorite', TYPE_FAVORITE_LIKE)->first();
     if (!isset($favorite)) {
         Favorite::create(['model_name' => 'User', 'model_id' => $id, 'follow_id' => $input['user_id'], 'type_favorite' => TYPE_FAVORITE_LIKE]);
     }
     // else {
     // 	Favorite::where('model_name', 'User')
     // 		->where('model_id', $id)
     // 		->where('follow_id', $input['user_id'])
     // 		->where('type_favorite', TYPE_FAVORITE_LIKE)
     // 		->delete();
     // }
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #10
0
 public function post()
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     //check user active
     $checkUser = User::find($input['user_id'])->status;
     if (isset($checkUser) && $checkUser == INACTIVE) {
         throw new Prototype\Exceptions\UserStatusErrorException();
     }
     // create product
     $inputSubmit = ['name' => $input['name'], 'user_id' => $input['user_id'], 'category_id' => $input['category_id'], 'type_id' => $input['type_id'], 'price_id' => CommonProduct::getPriceId($input['price']), 'price' => $input['price'], 'lat' => $input['lat'], 'long' => $input['long'], 'description' => $input['description'], 'avatar' => $input['avatar'], 'address' => $input['address'], 'city_id' => $input['city_id'], 'city' => Common::getModelField($input['city_id'], 'City', 'name'), 'position' => 1, 'status' => INACTIVE, 'start_time' => Carbon\Carbon::now()];
     $id = Product::create($inputSubmit)->id;
     // images product
     if (isset($input['image_url']) && count($input['image_url']) > 0) {
         foreach ($input['image_url'] as $key => $value) {
             $inputImage = array('product_id' => $id, 'image_url' => $value);
             ProductImage::create($inputImage);
         }
     }
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }
コード例 #11
0
 public function listHidden()
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     return CommonProduct::returnProductDeleted();
 }
コード例 #12
0
 public function deleteUserMessage($chatId)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $data = Common::queryCommonMessage($input, $chatId);
     $data = $data->delete();
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }