diff --git a/app/Http/Controllers/APIs/Customer_API/CustomerControllerApi.php b/app/Http/Controllers/APIs/Customer_API/CustomerControllerApi.php index 94292a4..3c4214d 100644 --- a/app/Http/Controllers/APIs/Customer_API/CustomerControllerApi.php +++ b/app/Http/Controllers/APIs/Customer_API/CustomerControllerApi.php @@ -187,4 +187,29 @@ class CustomerControllerApi extends Controller return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } + + + /** + * Created By : sayli Raut + * Created at : 15 July 2024 + * Use : To get user subscription status. + */ + public function CheckSubscription() + { + try { + $token = readHeaderToken(); + + if ($token) { + $customerIamId = $token['sub']; + $response = $this->CustomerApiServices->CheckSubscription($customerIamId); + return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), ['is_subscribed' => $response], 200); + + } else { + return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + } + } catch (Exception $e) { + Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } } diff --git a/app/Http/Controllers/APIs/Customer_API/SubscriptionController.php b/app/Http/Controllers/APIs/Customer_API/SubscriptionController.php index be81089..f5bde1d 100644 --- a/app/Http/Controllers/APIs/Customer_API/SubscriptionController.php +++ b/app/Http/Controllers/APIs/Customer_API/SubscriptionController.php @@ -85,7 +85,7 @@ class SubscriptionController extends Controller } catch (\Exception $e) { Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong')); } } diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index 30baad0..51cffb8 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -86,178 +86,184 @@ class ManageNotificationsController extends Controller * Use : To add notification . */ - public function store_notificaton_data(Request $request) - { - try { - $request->validate([ - 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', - ]); + public function store_notificaton_data(Request $request) + { + try { + $request->validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', + ]); - DB::beginTransaction(); + DB::beginTransaction(); - if (isset($request->image)) { - $image = $request->image; - $image_db = null; - } else { - $image = null; - $image_db = $request->image; - } + if (isset($request->image)) { + $image = $request->image; + $image_db = null; + } else { + $image = null; + $image_db = $request->image; + } - $tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db); - $imagePath = ListingImageUrl('notification_images', $tnormalImage); + $tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db); + $imagePath = ListingImageUrl('notification_images', $tnormalImage); - $states = $request->states; + $states = $request->states; - $dateTime = now(); - $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); - $iamPrincipals = Subscriptions::select('iam_principal_xid') - ->where('next_payment_date', '>=', $formattedDateTime) - ->get(); + $dateTime = now(); + $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); + $iamPrincipals = Subscriptions::select('iam_principal_xid') + ->where('next_payment_date', '>=', $formattedDateTime) + ->get(); - $iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid'); + $iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid'); - $subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds) - ->where('is_active', 1) - ->where('notification_status', 1) - ->where('principal_type_xid', 3) - ->whereIn('state_xid', $states) - ->get(); + $subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds) + ->where('is_active', 1) + ->where('notification_status', 1) + ->where('principal_type_xid', 3) + ->whereIn('state_xid', $states) + ->get(); - if ($request->user_type == 1) { - $allCustomerOneSignalIds = $subscribe->pluck('id'); - $UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get(); + $scheduled = false; - foreach ($UserData as $customerIdItem) { - // user_type 1 = subscribed user - if ($request->schedule_radio1 == 1 && $request->schedule_date) { - // Scheduled Notification - NotificationDetails::create([ - 'principal_xid' => $customerIdItem->id, - 'description' => $request->description, - 'type' => $request->title, - 'image' => $imagePath, - 'date_added' => $request->schedule_date, - 'is_schedule' => 1, - 'delivery_schedule' => $request->schedule_date, - 'is_active' => 0, + if ($request->user_type == 1) { + $allCustomerOneSignalIds = $subscribe->pluck('id'); + $UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get(); - ]); - } else { - // Immediate Notification - if ($customerIdItem->one_signal_player_id) { - onesignalhelper::sendNotificationApi( - $customerIdItem->one_signal_player_id, - $request->title, - $request->description, - 'Dashboard Notification', - $imagePath, - $id = null - ); - } - onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath); - } - } - } elseif ($request->user_type == 2) { - //user_type 2 unsubscribed users - $allPrincipalIds = IamPrincipal::where('principal_type_xid', 3) - ->pluck('id'); + foreach ($UserData as $customerIdItem) { + // user_type 1 = subscribed user + if ($request->schedule_radio1 == 1 && $request->schedule_date) { + // Scheduled Notification + NotificationDetails::create([ + 'principal_xid' => $customerIdItem->id, + 'description' => $request->description, + 'type' => $request->title, + 'image' => $imagePath, + 'date_added' => $request->schedule_date, + 'is_schedule' => 1, + 'delivery_schedule' => $request->schedule_date, + 'is_active' => 0, + ]); + $scheduled = true; + } else { + // Immediate Notification + if ($customerIdItem->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $customerIdItem->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath); + } + } + } elseif ($request->user_type == 2) { + // user_type 2 unsubscribed users + $allPrincipalIds = IamPrincipal::where('principal_type_xid', 3) + ->pluck('id'); - $subscribedIds = Subscriptions::select('iam_principal_xid') - ->where('next_payment_date', '>=', $formattedDateTime) - ->pluck('iam_principal_xid'); + $subscribedIds = Subscriptions::select('iam_principal_xid') + ->where('next_payment_date', '>=', $formattedDateTime) + ->pluck('iam_principal_xid'); - $unsubscribedIds = $allPrincipalIds->diff($subscribedIds); + $unsubscribedIds = $allPrincipalIds->diff($subscribedIds); - $unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds) - ->where('is_active', 1) - ->where('notification_status', 1) - ->whereIn('state_xid', $states) - ->get(); + $unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds) + ->where('is_active', 1) + ->where('notification_status', 1) + ->whereIn('state_xid', $states) + ->get(); - $allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id'); - $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); + $allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id'); + $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); - foreach ($restaurantData as $restaurantsData) { - if ($request->schedule_radio1 == 1 && $request->schedule_date) { - // Scheduled Notification - NotificationDetails::create([ - 'principal_xid' => $restaurantsData->id, - 'description' => $request->description, - 'type' => $request->title, - 'image' => $imagePath, - 'date_added' => $request->schedule_date, - 'is_schedule' => 1, - 'delivery_schedule' => $request->schedule_date, - 'is_active' => 0, + foreach ($restaurantData as $restaurantsData) { + if ($request->schedule_radio1 == 1 && $request->schedule_date) { + // Scheduled Notification + NotificationDetails::create([ + 'principal_xid' => $restaurantsData->id, + 'description' => $request->description, + 'type' => $request->title, + 'image' => $imagePath, + 'date_added' => $request->schedule_date, + 'is_schedule' => 1, + 'delivery_schedule' => $request->schedule_date, + 'is_active' => 0, + ]); + $scheduled = true; + } else { + // Immediate Notification + if ($restaurantsData->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $restaurantsData->one_signal_player_id, + $request->title, + $request->description, + $request->title, + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath); + } + } + } elseif ($request->user_type == 3) { + // user_type 3 = subscribed and unsubscribed users + $userQuery = IamPrincipal::where('is_active', 1) + ->where('notification_status', 1) + ->where('principal_type_xid', 3) + ->whereIn('state_xid', $states); + $allUserOneSignalIds = $userQuery->pluck('id'); + $UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get(); - ]); - } else { - // Immediate Notification - if ($restaurantsData->one_signal_player_id) { - onesignalhelper::sendNotificationApi( - $restaurantsData->one_signal_player_id, - $request->title, - $request->description, - $request->title, - $imagePath, - $id = null - ); - } - onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath); - } - } - } elseif ($request->user_type == 3) { - // user_type 3 = subscribed and unsubscribed users - $userQuery = IamPrincipal::where('is_active', 1) - ->where('notification_status', 1) - ->where('principal_type_xid', 3) - ->whereIn('state_xid', $states); + foreach ($UserData as $CustomerData) { + if ($request->schedule_radio1 == 1 && $request->schedule_date) { + // Scheduled Notification + NotificationDetails::create([ + 'principal_xid' => $CustomerData->id, + 'description' => $request->description, + 'type' => $request->title, + 'image' => $imagePath, + 'date_added' => $request->schedule_date, + 'is_schedule' => 1, + 'delivery_schedule' => $request->schedule_date, + 'is_active' => 0, + ]); + $scheduled = true; + } else { + // Immediate Notification + if ($CustomerData->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $CustomerData->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath); + } + } + } - $allUserOneSignalIds = $userQuery->pluck('id'); - $UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get(); + DB::commit(); - foreach ($UserData as $CustomerData) { - if ($request->schedule_radio1 == 1 && $request->schedule_date) { - // Scheduled Notification - NotificationDetails::create([ - 'principal_xid' => $CustomerData->id, - 'description' => $request->description, - 'type' => $request->title, - 'image' => $imagePath, - 'date_added' => $request->schedule_date, - 'is_schedule' => 1, - 'delivery_schedule' => $request->schedule_date, - 'is_active' => 0, + if ($scheduled) { + return jsonResponseWithSuccessMessage(__('success.save_data_scheduled')); + } else { + return jsonResponseWithSuccessMessage(__('success.save_data_immediate')); + } + } catch (Exception $e) { + DB::rollBack(); + Log::error("Notification send Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } - ]); - } else { - // Immediate Notification - if ($CustomerData->one_signal_player_id) { - onesignalhelper::sendNotificationApi( - $CustomerData->one_signal_player_id, - $request->title, - $request->description, - 'Dashboard Notification', - $imagePath, - $id = null - ); - } - onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath); - } - } - } - - DB::commit(); - return jsonResponseWithSuccessMessage(__('success.save_data')); - } catch (Exception $e) { - DB::rollBack(); - Log::error("Notification send Failed " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); - } - } - diff --git a/app/Http/Controllers/Admin/ManageRestrauntController.php b/app/Http/Controllers/Admin/ManageRestrauntController.php index 10f4d39..3546f07 100644 --- a/app/Http/Controllers/Admin/ManageRestrauntController.php +++ b/app/Http/Controllers/Admin/ManageRestrauntController.php @@ -12,6 +12,7 @@ use Exception; use App\Helpers\onesignalhelper; use App\Models\IamPrincipal; use App\Models\ManageState; +use App\Models\RestaurantClosedHour; use App\Models\RestaurantTimeInterval; use Illuminate\Support\Facades\Log; use Maatwebsite\Excel\Facades\Excel; @@ -29,11 +30,11 @@ class ManageRestrauntController extends Controller $activeQuery = $request->query('active'); if ($activeQuery == 1) { - $restaurant = ManageRestaurant::where('is_active', 1)->latest()->get(); + $restaurant = ManageRestaurant::with('state')->where('is_active', 1)->latest()->get(); } else if ($activeQuery == 0 && $activeQuery != null) { - $restaurant = ManageRestaurant::where('is_active', 0)->latest()->get(); + $restaurant = ManageRestaurant::with('state')->where('is_active', 0)->latest()->get(); } else { - $restaurant = ManageRestaurant::latest()->get(); + $restaurant = ManageRestaurant::with('state')->latest()->get(); } return view('Admin.pages.manage_restaurants.manage_restaurants', compact('restaurant')); } @@ -87,6 +88,7 @@ class ManageRestrauntController extends Controller $restaurant->try_on_4 = $request->input('try_on_4'); $restaurant->save(); + // Storing operating hours foreach ($request->input('operating_hours') as $day => $hours) { OperatingHour::create([ 'manage_restaurant_xid' => $restaurant->id, @@ -96,6 +98,7 @@ class ManageRestrauntController extends Controller ]); } + // Storing restaurant time interval $restTimeInterval = new RestaurantTimeInterval(); $restTimeInterval->manage_restaurants_xid = $restaurant->id; $restTimeInterval->time_hours = $request->timeHours; @@ -103,8 +106,18 @@ class ManageRestrauntController extends Controller $restTimeInterval->quantity = $request->timeQuantity; $restTimeInterval->save(); - $imagePath = ListingImageUrl('restaurant_images', $restaurant->image); + // Storing closed restaurant date and time + if ($request->has('closed_date')) { + $ClosedTime = new RestaurantClosedHour(); + $ClosedTime->restaurant_id = $restaurant->id; + $ClosedTime->day = $request->closed_date; + $ClosedTime->start_time = $request->closed_start_time; + $ClosedTime->end_time = $request->closed_end_time; + $ClosedTime->save(); + } + // Sending notifications + $imagePath = ListingImageUrl('restaurant_images', $restaurant->image); $allCustomerOneSignalIds = IamPrincipal::select('id', 'one_signal_player_id')->where('is_active', 1)->where('notification_status', 1)->where('principal_type_xid', 3)->get(); $title = "New " . $restaurant->name . " is added"; $message = "New Restaurant is Now Live."; @@ -125,7 +138,6 @@ class ManageRestrauntController extends Controller onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath); } - DB::commit(); return jsonResponseWithSuccessMessage(__('success.save_data')); } catch (Exception $e) { @@ -136,6 +148,7 @@ class ManageRestrauntController extends Controller } + /* Created By : Sayli Raut Created at : 29 May 2024 @@ -146,6 +159,7 @@ class ManageRestrauntController extends Controller try { $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week'); $restaurantItem = ManageRestaurant::with('timeInterval')->where('id', $id)->first(); + $restaurantClosedTime = RestaurantClosedHour::with('restaurant')->where('restaurant_id', $id)->first(); $timeInterval = $restaurantItem->timeInterval->first(); $state = ManageState::where('is_active', 1)->get()->toArray(); @@ -157,7 +171,8 @@ class ManageRestrauntController extends Controller 'operating_hours', 'state', - 'timeInterval' + 'timeInterval', + 'restaurantClosedTime' ) ); } catch (Exception $e) { @@ -245,6 +260,26 @@ class ManageRestrauntController extends Controller ]); } + // Handle closed restaurant data + $closedTime = RestaurantClosedHour::where('restaurant_id', $restaurant->id)->first(); + + if ($closedTime) { + // Update existing record + $closedTime->update([ + 'day' => $request->input('closed_date'), + 'start_time' => $request->input('closed_start_time'), + 'end_time' => $request->input('closed_end_time'), + ]); + } else { + // Create new record + RestaurantClosedHour::create([ + 'restaurant_id' => $restaurant->id, + 'day' => $request->input('closed_date'), + 'start_time' => $request->input('closed_start_time'), + 'end_time' => $request->input('closed_end_time'), + ]); + } + DB::commit(); return jsonResponseWithSuccessMessage(__('success.update_data')); @@ -258,6 +293,7 @@ class ManageRestrauntController extends Controller + /* Created By : Sayli Raut Created at : 29 May 2024 diff --git a/app/Http/Helpers/Webhelper.php b/app/Http/Helpers/Webhelper.php index 30aa672..7d87aee 100644 --- a/app/Http/Helpers/Webhelper.php +++ b/app/Http/Helpers/Webhelper.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Session; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Tymon\JWTAuth\Facades\JWTAuth; +use GuzzleHttp\Client; /** * Created By : sayli raut @@ -168,17 +169,82 @@ if (!function_exists('readRestHeaderToken')) { if (!function_exists('generateOTP')) { - function generateOTP() - { - // Define the length of the OTP - $otpLength = 4; + function generateOTP() + { + // Define the length of the OTP + $otpLength = 4; - // Generate a random OTP with $otpLength digits - $otp = ''; - for ($i = 0; $i < $otpLength; $i++) { - $otp .= rand(0, 9); + // Generate a random OTP with $otpLength digits + $otp = ''; + for ($i = 0; $i < $otpLength; $i++) { + $otp .= rand(0, 9); + } + return $otp; } - return $otp; } } + +/** + * Created by : Hritik RD + * Created at : 12 July 2024 + * Use : To Get Opening hours of Restaurant By NAME based on Google Maps using Google Places APIs + */ + +if (!function_exists('getOpeningHoursOfRestaurant')) { + function getOpeningHoursOfRestaurant($restaurantName) + { + + $googlePlaceApiKey = config('constants.googlePlaces.api_key'); // Your webhook secret key + // dd($googlePlaceApiKey); + + $client = new Client(); + $url = 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json'; + + $response = $client->get($url, [ + 'query' => [ + 'fields' => 'place_id', + 'input' => $restaurantName, + 'inputtype' => 'textquery', + 'key' => $googlePlaceApiKey + ] + ]); + $placeData = json_decode($response->getBody(), true); + + if (isset($placeData['candidates'][0]['place_id'])) { + $placeId = $placeData['candidates'][0]['place_id']; + // return $placeId; + } else { + $placeId = "N/A"; + // return response()->json($placeId); + return $placeId; + } + + + // $placeId = 'ChIJT3dpYcy35zsRLxY5KTTMqhU'; // You can also pass this as a parameter if needed + $client = new Client(); + $url = 'https://maps.googleapis.com/maps/api/place/details/json'; + + $response = $client->get($url, [ + 'query' => [ + 'fields' => 'name,rating,formatted_phone_number,opening_hours', + 'place_id' => $placeId, + 'key' => $googlePlaceApiKey + ] + ]); + + $data = json_decode($response->getBody(), true); + if (isset($data['result']['opening_hours']['weekday_text'])) { + $hours = $data['result']['opening_hours']['weekday_text']; + // return response()->json(['place_id' => $placeId]); + } else { + $hours = "N/A"; + } + return $hours ; + // dd($data); + // return response()->json($data); + + } } + + + diff --git a/app/Models/ManageRestaurant.php b/app/Models/ManageRestaurant.php index d1691a0..1802769 100644 --- a/app/Models/ManageRestaurant.php +++ b/app/Models/ManageRestaurant.php @@ -60,5 +60,10 @@ class ManageRestaurant extends Model return $this->hasMany(RestaurantTimeInterval::class, 'manage_restaurants_xid', 'id'); } + public function closedRestaurant() + { + return $this->hasMany(RestaurantClosedHour::class, 'restaurant_id', 'id'); + } + } diff --git a/app/Models/RestaurantClosedHour.php b/app/Models/RestaurantClosedHour.php new file mode 100644 index 0000000..161900b --- /dev/null +++ b/app/Models/RestaurantClosedHour.php @@ -0,0 +1,21 @@ +belongsTo(ManageRestaurant::class); + } +} diff --git a/app/Services/APIs/CustomerAPIs/CustomerApiServices.php b/app/Services/APIs/CustomerAPIs/CustomerApiServices.php index da5b8f3..561c636 100644 --- a/app/Services/APIs/CustomerAPIs/CustomerApiServices.php +++ b/app/Services/APIs/CustomerAPIs/CustomerApiServices.php @@ -12,43 +12,43 @@ use Illuminate\Support\Facades\DB; class CustomerApiServices { public function getUserProfileDetailService($customerIamId) -{ - try { - $user = IamPrincipal::findOrFail($customerIamId); + { + try { + $user = IamPrincipal::findOrFail($customerIamId); - $data = IamPrincipal::select( - 'id', - 'first_name', - 'last_name', - 'email_address', - 'phone_number', - 'date_of_birth', - 'state_xid', - 'profile_photo', - 'referral_code' - )->find($user->id); + $data = IamPrincipal::select( + 'id', + 'first_name', + 'last_name', + 'email_address', + 'phone_number', + 'date_of_birth', + 'state_xid', + 'profile_photo', + 'referral_code' + )->find($user->id); - $dateTime = now(); - $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); + $dateTime = now(); + $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); - $isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId) - ->where('next_payment_date', '>=', $formattedDateTime) - ->exists(); + $isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId) + ->where('next_payment_date', '>=', $formattedDateTime) + ->exists(); - if ($data->profile_photo) { - $data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo); - } else { - $data->profile_photo = asset('public/assets/img/blankProfile.png'); + if ($data->profile_photo) { + $data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo); + } else { + $data->profile_photo = asset('public/assets/img/blankProfile.png'); + } + + $data->is_subscribed = $isSubscribedUser; + + return $data; + } catch (Exception $ex) { + Log::error('Customer Get data service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } - - $data->is_subscribed = $isSubscribedUser; - - return $data; - } catch (Exception $ex) { - Log::error('Customer Get data service failed : ' . $ex->getMessage()); - return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } -} @@ -143,4 +143,21 @@ class CustomerApiServices return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + public function CheckSubscription($customerIamId) + { + try { + + $dateTime = now(); + $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); + $isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId) + ->where('next_payment_date', '>=', $formattedDateTime) + ->exists(); + + return $isSubscribedUser; + } catch (Exception $ex) { + Log::error('Customer Get data service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } } diff --git a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php index 79a7bca..793b849 100644 --- a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php @@ -23,7 +23,7 @@ class RestaurantApiServices public function getCoordinates($customerIamId) { try { - $restaurants = ManageRestaurant::with('operatingHours')->select( + $restaurants = ManageRestaurant::with('operatingHours','closedRestaurant')->select( 'id', 'name', 'image', @@ -43,6 +43,7 @@ class RestaurantApiServices ->where('restaurant_xid', $restaurant['id']) ->exists(); $restaurant['is_favourite'] = $isFavourite; + // $restaurant['operating_hours'] = getOpeningHoursOfRestaurant($restaurant['name']);// will update later } return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $restaurants, 200); @@ -121,6 +122,8 @@ class RestaurantApiServices ->exists(); $rest->is_favourite = $isFavourite; + + $redeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId) ->where('manage_restaurants_xid', $rest->id) ->where('is_redeem', "1") @@ -131,6 +134,10 @@ class RestaurantApiServices // $timeIntervalHours = $Timeinterval->time_hours; $restTimeHours = $restTime->time_hours; + //this below code is updated by hritik on 12-07-2024 by adding restaurant opening hours dynamically from Google + + // $rest->operating_hours = getOpeningHoursOfRestaurant($rest->name); //will update later + // $greaterTime = max($timeIntervalHours, $restTimeHours); diff --git a/config/constants.php b/config/constants.php index ff75c52..105380c 100644 --- a/config/constants.php +++ b/config/constants.php @@ -21,5 +21,9 @@ return [ 'stripe_secret_key' => env('STRIPE_SECRET'), 'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'), ], + + 'googlePlaces'=>[ + 'api_key'=>env('GOOGLE_PLACE_API_KEY') + ] ]; diff --git a/database/migrations/2024_07_12_094733_create_restaurant_closed_hours_table.php b/database/migrations/2024_07_12_094733_create_restaurant_closed_hours_table.php new file mode 100644 index 0000000..b5a5b35 --- /dev/null +++ b/database/migrations/2024_07_12_094733_create_restaurant_closed_hours_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('restaurant_id'); + $table->string('day'); + $table->time('start_time')->nullable(); + $table->time('end_time')->nullable(); + $table->timestamps(); + + $table->foreign('restaurant_id')->references('id')->on('manage_restaurants')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('restaurant_closed_hours'); + } +}; diff --git a/public/assets/js/admin/manage_restaurant/add_restaurant.js b/public/assets/js/admin/manage_restaurant/add_restaurant.js index ce4f7d0..48ec218 100644 --- a/public/assets/js/admin/manage_restaurant/add_restaurant.js +++ b/public/assets/js/admin/manage_restaurant/add_restaurant.js @@ -64,6 +64,16 @@ $(document).on("click", "#update_restaurant_btn", function (e) { required: true, number: true, min: 1 + }, + closed_start_time: { + required: function (element) { + return $('input[name="closed_date"]').val() !== ''; + } + }, + closed_end_time: { + required: function (element) { + return $('input[name="closed_date"]').val() !== ''; + } } }, messages: { @@ -122,11 +132,17 @@ $(document).on("click", "#update_restaurant_btn", function (e) { required: "Please enter the maximum number of cocktails", number: "Maximum number of cocktails must be a number", min: "Maximum number of cocktails must be greater than 0" + }, + closed_start_time: { + required: "Please select the start time for closing hours" + }, + closed_end_time: { + required: "Please select the end time for closing hours" } }, errorClass: 'error-message', submitHandler: function (form) { - e.preventDefault(); // Prevent default form submission + e.preventDefault(); var form = $('#update_restaurant_form')[0]; var formData = new FormData(form); @@ -163,7 +179,6 @@ $(document).on("click", "#update_restaurant_btn", function (e) { }, error: function (xhr, status, error) { toastr.error('Something Went Wrong'); - // Handle error }, complete: function () { $('#update_restaurant_btn').attr('disabled', false); @@ -173,5 +188,3 @@ $(document).on("click", "#update_restaurant_btn", function (e) { } }); }); - - diff --git a/resources/lang/en/success.php b/resources/lang/en/success.php index d09ced8..122584c 100644 --- a/resources/lang/en/success.php +++ b/resources/lang/en/success.php @@ -34,5 +34,8 @@ return [ 'authentic_success' => 'Authentication Successful', 'confirmed_password' => 'please confirm your passsword', 'redeemed_successfully' => 'Referral code redeemed successfully.', + 'save_data_scheduled' => 'Notification Schedule Successfully.', + 'save_data_immediate' => 'Notification Sent Successfully.', + ]; diff --git a/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php index a389400..e251dae 100644 --- a/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php +++ b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php @@ -57,7 +57,10 @@
- + +
@@ -138,10 +141,12 @@
-
Delivery Schedule
+ +
-
When should this message start sending?
+
@@ -182,193 +187,212 @@
@endsection @section('section_script') - - - + + + - + @endsection diff --git a/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php b/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php index 8101dfb..949e8d2 100644 --- a/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php +++ b/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php @@ -1,83 +1,91 @@ @extends('Admin.layouts.master') @section('content') -@php -$currentPage = 'manage-notification'; -@endphp -
-
-
-
-
- + @php + $currentPage = 'manage-notification'; + @endphp +
+
+
+
+ -
-
-
-
-
-
-
-
- - - - - - - - - -
Notification content :Created Date :
{{ $notification->description }}{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}
-
-
- - - - {{-- --}} - - + +
+
+
+
+
+
+
+
+
Recipients :Last Modified Date :
+ + + + + + + + - + + - -
Message :Description :Created Date :
{{ $notification->type }}{{ $notification->description }}@if($notification->notification->principal_type_xid == '3') - Customer - @else - Resturant - @endif - {{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }} +
-
+ +
+
+ + + + + {{-- --}} + + + + + + + + +
Recipients :Image :Last Modified Date :
+ @if ($notification->notification->principal_type_xid == '3') + Customer + @else + Resturant + @endif + + Notification Image +
+
-
+
-
+
+
- - - +
@endsection - diff --git a/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php b/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php index bfb03c6..68e8b7b 100644 --- a/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php @@ -24,37 +24,33 @@ -
+
-
+
-
+
-
+
@@ -63,52 +59,52 @@
- - your image +
-
+
- - - +
+ + +
-
+
-
+
-
- +
+
-
+
@@ -117,7 +113,7 @@
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day) -
+
+
+
+ + +
+
+ + + + +
+
+ + +
+
+ +
+
+ + +
+
- -
-
- - - - - -
-
-
- +
+
+
+ + + + +
+
+ +
+
-
-
@@ -201,4 +219,10 @@ theme: 'snow' }); + @endsection diff --git a/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php b/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php index 82cfdea..8b89bef 100644 --- a/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php @@ -123,6 +123,7 @@ $timeQuantity = $timeInterval->quantity ?? ''; @endphp +
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+