This commit is contained in:
sayliraut
2024-05-31 13:24:45 +05:30
parent 913d6acaa3
commit 051bc0577b
3 changed files with 17 additions and 5 deletions

View File

@@ -47,6 +47,7 @@ class RestaurantControllerApi extends Controller
*/
public function addToFavourite(Request $request)
{
dd("hii");
try {
$token = readHeaderToken();

View File

@@ -48,22 +48,32 @@ class RestaurantApiServices
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.restaurant_already_favourite'), 409);
}
$favRestaurant = new CustomerFavouriteRestaurant();
$favRestaurant->principal_xid = $customerIamId;
$favRestaurant->restaurant_xid = $restaurant->id;
$favRestaurant->principal_xid = $customerIamId;
$favRestaurant->restaurant_xid = $restaurant->id;
$favRestaurant->save();
DB::commit();
Log::info("details" . $favRestaurant);
return jsonResponseWithSuccessMessage(__('auth.data_updated_successfully'), 200);
} catch (Exception $ex) {
} catch (\Exception $ex) {
DB::rollBack();
Log::error('Favourite Restaurant service failed : ' . $ex->getMessage());
Log::error('Favourite Restaurant service failed: ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
public function listFavRestaurant($customerIamId)
{
try {

View File

@@ -104,5 +104,6 @@ return [
'otp_expired_invalid' => 'Invalid OTP or expired.',
'legally_21' => 'You are legally over the age of 21. Proceed to the next page.',
'not_legally_21' => 'Sorry, you are not legally over the age of 21. Exit the page.',
'restaurant_already_favourite' => 'restaurant already in favourite list'
];