change
This commit is contained in:
@@ -47,6 +47,7 @@ class RestaurantControllerApi extends Controller
|
||||
*/
|
||||
public function addToFavourite(Request $request)
|
||||
{
|
||||
dd("hii");
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user