search restaurant
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
|
||||
use App\Services\APIs\RestaurantService\RestAuthApiService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -35,7 +36,7 @@ class RestAuthApiController extends Controller
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 30 May 2024
|
||||
* Use : Restaurant State.
|
||||
@@ -50,7 +51,7 @@ class RestAuthApiController extends Controller
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 30 May 2024
|
||||
* Use : Restaurant Registration.
|
||||
@@ -88,8 +89,8 @@ class RestAuthApiController extends Controller
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 31 May 2024
|
||||
* Use : Restaurant login.
|
||||
*/
|
||||
@@ -112,7 +113,7 @@ class RestAuthApiController extends Controller
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 31 May 2024
|
||||
* Use : Forgot password for restaurant.
|
||||
@@ -146,7 +147,7 @@ class RestAuthApiController extends Controller
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 31 May 2024
|
||||
* Use : verify otp for restaurant.
|
||||
@@ -230,4 +231,22 @@ class RestAuthApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 12 June 2024
|
||||
* Use : Search Restaurant .
|
||||
*/
|
||||
public function searchRest(Request $request)
|
||||
{
|
||||
try {
|
||||
return $this->RestAuthApiService->searchRest($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Login API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class RestAuthApiService
|
||||
public function viewresyaurant()
|
||||
{
|
||||
try {
|
||||
$data = ManageRestaurant::select('id', 'name','description','restaurant_id','address','image','bio','try_on_1','try_on_2','try_on_3','try_on_4','exclusion','latitude','longtitude')->where('is_active', 1)->get()->toArray();
|
||||
$data = ManageRestaurant::select('id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude')->where('is_active', 1)->get()->toArray();
|
||||
return $data;
|
||||
} catch (Exception $ex) {
|
||||
DB::rollBack();
|
||||
@@ -226,32 +226,36 @@ class RestAuthApiService
|
||||
if (!$iamPrincipal) {
|
||||
$errors[] = __('auth.failed_to_verify_otp');
|
||||
return jsonResponseWithErrorMessageApi(
|
||||
$errors,403
|
||||
);
|
||||
$errors,
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the provided OTP matches the stored OTP
|
||||
if ($iamPrincipal->otp_code !== $request->otp) {
|
||||
$errors[] = __('auth.invalid_otp');
|
||||
return jsonResponseWithErrorMessageApi(
|
||||
$errors,403
|
||||
);
|
||||
$errors,
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the OTP is still valid
|
||||
if (Carbon::now()->gt($iamPrincipal->valid_till)) {
|
||||
$errors[] = __('auth.otp_expired');
|
||||
return jsonResponseWithErrorMessageApi(
|
||||
$errors,403
|
||||
);
|
||||
$errors,
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the OTP has already been used
|
||||
if ($iamPrincipal->is_used === 1) {
|
||||
$errors[] = __('auth.otp_already_used');
|
||||
return jsonResponseWithErrorMessageApi(
|
||||
$errors,403
|
||||
);
|
||||
$errors,
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -373,4 +377,27 @@ class RestAuthApiService
|
||||
}
|
||||
return $otp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function searchRest($request)
|
||||
{
|
||||
try {
|
||||
$searchQuery = $request->input('search_data');
|
||||
|
||||
$query = ManageRestaurant::select('id', 'name')->where('is_active', 1);
|
||||
|
||||
if ($searchQuery) {
|
||||
$query->where(function ($q) use ($searchQuery) {
|
||||
$q->where('name', 'like', '%' . $searchQuery . '%')
|
||||
->orWhere('address', 'like', '%' . $searchQuery . '%');
|
||||
});
|
||||
}
|
||||
$restaurants = $query->get();
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), $restaurants, 200);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage());
|
||||
return response()->json(__('something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ Route::middleware(['restaurantApiBasicAuth'])->group(function () {
|
||||
Route::post('/v1/rest-verify-otp', [RestAuthApiController::class, 'restVerifyOTP']);
|
||||
Route::post('/v1/rest-change-password', [RestAuthApiController::class, 'restChangePassword']);
|
||||
Route::post('/v1/rest-resend-otp', [RestAuthApiController::class, 'restResendOtp']);
|
||||
Route::post('/v1/search-rest', [RestAuthApiController::class, 'searchRest']);
|
||||
|
||||
|
||||
Route::group(['middleware' => ['restaurant.jwt.verify']], function () {
|
||||
// //*******************************************************Restaurant profile********************************************************
|
||||
|
||||
Reference in New Issue
Block a user