change
This commit is contained in:
@@ -17,7 +17,7 @@ class RestaurantControllerApi extends Controller
|
||||
$this->RestaurantApiServices = $RestaurantApiServices;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 30 May 2024
|
||||
* Use : To get restaurant.
|
||||
@@ -40,7 +40,7 @@ class RestaurantControllerApi extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 30 May 2024
|
||||
* Use : To add favourite.
|
||||
@@ -70,7 +70,7 @@ class RestaurantControllerApi extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 30 May 2024
|
||||
* Use : To list of fav restaurant.
|
||||
@@ -93,7 +93,7 @@ class RestaurantControllerApi extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 31 May 2024
|
||||
* Use : To detail of specific restaurant.
|
||||
@@ -116,4 +116,36 @@ class RestaurantControllerApi extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 04 June 2024
|
||||
* Use : To remove from favourite.
|
||||
*/
|
||||
public function removeFromFavourite(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return jsonResponseWithErrorMessageApi($validator->errors()->first(), 400);
|
||||
}
|
||||
$response = $this->RestaurantApiServices->removeFromFavourite($customerIamId, $request);
|
||||
return $response;
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Passport function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,4 +122,33 @@ class RestaurantApiServices
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeFromFavourite($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$restaurant = ManageRestaurant::where('short_id', $request->id)->where('is_active', '1')->first();
|
||||
if (!$restaurant) {
|
||||
return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404);
|
||||
}
|
||||
|
||||
$existingFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
->where('restaurant_xid', $restaurant->id)
|
||||
->first();
|
||||
if (!$existingFavourite) {
|
||||
return jsonResponseWithErrorMessage(__('auth.data_not_found'), 404);
|
||||
}
|
||||
if ($existingFavourite) {
|
||||
$existingFavourite->delete();
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_updated_successfully'), 200);
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
Log::error('Favourite Restaurant service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ Route::middleware(['customerApiBasicAuth'])->group(function () {
|
||||
Route::post('/v1/add-to-favourite', [RestaurantControllerApi::class, 'addToFavourite']);
|
||||
Route::get('/v1/list-of-fav-restaurant', [RestaurantControllerApi::class, 'listFavRestaurant']);
|
||||
Route::get('/v1/list-of-coordinates', [RestaurantControllerApi::class, 'getCoordinates']);
|
||||
Route::post('/v1/remove-from-favourite', [RestaurantControllerApi::class, 'removeFromFavourite']);
|
||||
|
||||
|
||||
|
||||
//*******************************************************notification********************************************************
|
||||
|
||||
Reference in New Issue
Block a user