list of restaurant
This commit is contained in:
@@ -19,7 +19,7 @@ class RestaurantControllerApi extends Controller
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 28 May 2024
|
||||
* Created at : 30 May 2024
|
||||
* Use : To get restaurant.
|
||||
*/
|
||||
public function getCoordinates()
|
||||
@@ -42,7 +42,7 @@ class RestaurantControllerApi extends Controller
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 28 May 2024
|
||||
* Created at : 30 May 2024
|
||||
* Use : To add favourite.
|
||||
*/
|
||||
public function addToFavourite(Request $request)
|
||||
@@ -72,7 +72,7 @@ class RestaurantControllerApi extends Controller
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 28 May 2024
|
||||
* Created at : 30 May 2024
|
||||
* Use : To list of fav restaurant.
|
||||
*/
|
||||
public function listFavRestaurant()
|
||||
@@ -92,4 +92,34 @@ class RestaurantControllerApi extends Controller
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 31 May 2024
|
||||
* Use : To list of fav restaurant.
|
||||
*/
|
||||
public function DetailRestaurant(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'ids' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return jsonResponseWithErrorMessageApi($validator->errors()->first(), 400);
|
||||
}
|
||||
$response = $this->RestaurantApiServices->DetailRestaurant($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ class ManageRestaurant extends Model
|
||||
|
||||
return $shortId;
|
||||
}
|
||||
public function operatingHours()
|
||||
{
|
||||
return $this->hasMany(OperatingHour::class,'manage_restaurant_xid', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,16 +72,42 @@ class RestaurantApiServices
|
||||
->pluck('restaurant_xid')
|
||||
->toArray();
|
||||
|
||||
$restaurants = ManageRestaurant::whereIn('id', $customerFavouriteRestaurants)->get();
|
||||
$restaurants = ManageRestaurant::whereIn('id', $customerFavouriteRestaurants)->get();
|
||||
|
||||
foreach ($restaurants as &$res) {
|
||||
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
|
||||
}
|
||||
foreach ($restaurants as &$res) {
|
||||
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
|
||||
}
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_updated_successfully'), $restaurants ,200);
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_updated_successfully'), $restaurants, 200);
|
||||
} catch (Exception $ex) {
|
||||
Log::error('List of Favourite Restaurant service failed : ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function DetailRestaurant($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
$rawIds = $request->input('ids');
|
||||
Log::info('Raw ids: ' . $rawIds);
|
||||
|
||||
$ids = json_decode($rawIds, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$rawIds = trim($rawIds, '[]');
|
||||
$ids = array_map('trim', explode(',', $rawIds));
|
||||
|
||||
}
|
||||
$restaurants = ManageRestaurant::whereIn('short_id', $ids)->get();
|
||||
foreach ($restaurants as &$res) {
|
||||
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
|
||||
}
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $restaurants, 200);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error('DetailRestaurant service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ Route::post('/v1/delete_account', [CustomerControllerApi::class, 'destroyAccount
|
||||
|
||||
Route::post('/v1/add-to-favourite', [RestaurantControllerApi::class, 'addToFavourite']);
|
||||
Route::get('/v1/list-of-fav-restaurant', [RestaurantControllerApi::class, 'listFavRestaurant']);
|
||||
Route::post('/v1/detail-of-restaurant', [RestaurantControllerApi::class, 'DetailRestaurant']);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user