diff --git a/app/Console/Commands/ReinstateRestaurant.php b/app/Console/Commands/ReinstateRestaurant.php index 7b0c926..58a9599 100644 --- a/app/Console/Commands/ReinstateRestaurant.php +++ b/app/Console/Commands/ReinstateRestaurant.php @@ -30,59 +30,56 @@ class ReinstateRestaurant extends Command * Execute the console command. */ - public function handle() - { - try { - $recordsToUpdate = RedeemRestaurant::where('is_redeem', 1)->get(); + public function handle() + { + try { + $recordsToUpdate = RedeemRestaurant::where('is_redeem', 1)->get(); - foreach ($recordsToUpdate as $record) { - //find restaurant - $managerestaurant = ManageRestaurant::where('id', $record->manage_restaurants_xid)->first(); + foreach ($recordsToUpdate as $record) { + //find restaurant + $managerestaurant = ManageRestaurant::where('id', $record->manage_restaurants_xid)->first(); - $customerData = IamPrincipal::where('id', $record->iam_principal_xid)->where('notification_status', 1)->where('principal_type_xid',3)->first(); //fetch customer + $customerData = IamPrincipal::where('id', $record->iam_principal_xid)->where('notification_status', 1)->where('principal_type_xid', 3)->first(); //fetch customer - if ($managerestaurant && $managerestaurant->is_active == 1) { - $redeemDate = Carbon::parse($record->redeem_date); + if ($managerestaurant && $managerestaurant->is_active == 1) { + $redeemDate = Carbon::parse($record->redeem_date); - $fourHourPlusTimeOfRecord = $redeemDate->copy()->addHours(4); + $fourHourPlusTimeOfRecord = $redeemDate->copy()->addHours($managerestaurant->time_hours); - $currentTime = Carbon::now(); + $currentTime = Carbon::now(); - if ($currentTime > $fourHourPlusTimeOfRecord) { - $record->update([ - 'is_redeem' => 0, - 'redeem_date' => null, - 'count' => $record->count + 1, - 'is_redeemption_undone' => 0, - 'redeemption_undone_date' => null, - ]); - $restImage = ListingImageUrl('restaurant_images', $managerestaurant->image); - $title = "Your " . $managerestaurant->name . " Reinstate successfully"; - $message = "Your " . $managerestaurant->name . " Reinstate successfully"; - $content_type = 'Restaurant Reinstate'; - $imageUrl = $restImage; + if ($currentTime > $fourHourPlusTimeOfRecord) { + $record->update([ + 'is_redeem' => 0, + 'redeem_date' => null, + 'count' => $record->count + 1, + 'is_redeemption_undone' => 0, + 'redeemption_undone_date' => null, + ]); + $restImage = ListingImageUrl('restaurant_images', $managerestaurant->image); + $title = "Your " . $managerestaurant->name . " Reinstate successfully"; + $message = "Your " . $managerestaurant->name . " Reinstate successfully"; + $content_type = 'Restaurant Reinstate'; + $imageUrl = $restImage; - onesignalhelper::sendNotificationApi( - $customerData->one_signal_player_id, - $title, - $message, - $content_type, - $imageUrl, - $id = null - ); - Log::info('Reinstate of record done at ' . now()); - - onesignalhelper::StoreNotificationDetails($customerData->id, $content_type, $title, $restImage); - } - } - } - - Log::info('Reinstate task ran successfully at ' . now()); - } catch (\Exception $e) { - Log::error('Reinstate function failed: ' . $e->getMessage()); - } - - } + onesignalhelper::sendNotificationApi( + $customerData->one_signal_player_id, + $title, + $message, + $content_type, + $imageUrl, + $id = null + ); + Log::info('Reinstate of record done at ' . now()); + onesignalhelper::StoreNotificationDetails($customerData->id, $content_type, $title, $restImage); + } + } + } + Log::info('Reinstate task ran successfully at ' . now()); + } catch (\Exception $e) { + Log::error('Reinstate function failed: ' . $e->getMessage()); + } + } } diff --git a/app/Exports/CustomerExportSelected.php b/app/Exports/CustomerExportSelected.php deleted file mode 100644 index bcc92cc..0000000 --- a/app/Exports/CustomerExportSelected.php +++ /dev/null @@ -1,56 +0,0 @@ -ids = $ids; - } - - /** - * @return \Illuminate\Support\Collection - */ - public function collection() - { - $selectedCareIds = explode(',', $this->ids); - - $selected_customer = IamPrincipal::whereIn('id', $selectedCareIds) - ->orderBy('id', 'Desc') - ->select( - 'first_name', - 'email_address', - 'date_of_birth', - 'phone_number' - ) - ->get(); - return $selected_customer; - } - - /** - * @return array - */ - public function headings(): array - { - return [ - 'first_name', - 'email_address', - 'date_of_birth', - 'phone_number' - ]; - } -} - - - - diff --git a/app/Exports/FeedbakExport.php b/app/Exports/FeedbakExport.php new file mode 100644 index 0000000..605cf2f --- /dev/null +++ b/app/Exports/FeedbakExport.php @@ -0,0 +1,50 @@ +get()->map(function ($feedback) { + $feedbackType = 'N/A'; + if ($feedback->is_app_feedback) { + $feedbackType = 'App Feedback'; + } elseif ($feedback->is_restaurant_feedback) { + $feedbackType = 'Restaurant Feedback'; + } + + return [ + 'Customer Id' => $feedback->principal ? $feedback->principal->id : 'N/A', + 'First Name' => $feedback->principal ? $feedback->principal->first_name : 'N/A', + 'Last Name' => $feedback->principal ? $feedback->principal->last_name : 'N/A', + 'Feedback Reaction' => $feedback->feedbackReaction ? $feedback->feedbackReaction->feedback_reaction_title : 'N/A', + 'Comment' => $feedback->comment, + 'Date Received' => $feedback->created_at, + 'Feedback Type' => $feedbackType, + 'Restaurant Name' => $feedback->restaurant ? $feedback->restaurant->name : 'N/A', + ]; + }); + } + + public function headings(): array + { + return [ + 'Customer Id', + 'First Name', + 'Last Name', + 'Feedback Reaction', + 'Comment', + 'Date Received', + 'App Feedback', + 'Restaurant Feedback', + 'Restaurant Name' + + + ]; + } +} diff --git a/app/Exports/RestaurantExport.php b/app/Exports/RestaurantExport.php new file mode 100644 index 0000000..46c7f92 --- /dev/null +++ b/app/Exports/RestaurantExport.php @@ -0,0 +1,55 @@ +get(); + } + + //function header in excel + public function headings(): array + { + return [ + 'Restaurant Name', + 'Description', + 'Phone Number', + 'Restaurant Id', + 'Address', + 'Bio', + 'Try on 1', + 'Try on 2', + 'Try on 3', + 'Try on 4', + 'Exclusion', + 'Latitude', + 'Longitude', + 'Active staus' + ]; + } +} diff --git a/app/Exports/RestaurantExportSelected.php b/app/Exports/RestaurantExportSelected.php new file mode 100644 index 0000000..270b86e --- /dev/null +++ b/app/Exports/RestaurantExportSelected.php @@ -0,0 +1,69 @@ +ids = $ids; + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + + $selectedCareIds = explode(',', $this->ids); + + $selected_restaurant = ManageRestaurant::whereIn('id', $selectedCareIds) + ->orderBy('id', 'Desc') + ->select( + 'name', + 'description', + 'phone_number', + 'restaurant_id', + 'address', + 'bio', + 'try_on_1', + 'try_on_2', + 'try_on_3', + 'try_on_4', + 'exclusion', + 'latitude', + 'longtitude', + 'is_active' + ) + ->get(); + return $selected_restaurant; + } + + //function header in excel + public function headings(): array + { + return [ + 'Restaurant Name', + 'Description', + 'Phone Number', + 'Restaurant Id', + 'Address', + 'Bio', + 'Try on 1', + 'Try on 2', + 'Try on 3', + 'Try on 4', + 'Exclusion', + 'Latitude', + 'Longitude', + 'Active staus' + ]; + } +} diff --git a/app/Exports/customer_export.php b/app/Exports/customer_export.php index 9aad372..9f48382 100644 --- a/app/Exports/customer_export.php +++ b/app/Exports/customer_export.php @@ -13,14 +13,30 @@ class customer_export implements FromCollection , WithHeadings /** * @return \Illuminate\Support\Collection */ - public function collection() - { - return IamPrincipal::select( - 'first_name', - 'email_address', - 'date_of_birth', - 'phone_number' - )->get(); + + + public function collection(){ + return IamPrincipal::where('principal_type_xid',3) + ->select('first_name', + 'last_name', + 'email_address', + 'date_of_birth', + 'state_xid', + 'phone_number' + ) + ->get() + ->map(function ($customer) { + return [ + 'first_name' => $customer->first_name, + 'last_name' => $customer->last_name, + 'email_address' => $customer->email_address, + 'date_of_birth'=> \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), + 'state_xid' => $customer->state->name ?? '', // Access the state name and handle null + 'phone_number' => $customer->phone_number, + ]; + }); + + } //function header in excel @@ -28,9 +44,17 @@ class customer_export implements FromCollection , WithHeadings { return [ 'first_name', + 'last_name', 'email_address', 'date_of_birth', + 'state_name', 'phone_number' ]; - } + } + + + + + + } diff --git a/app/Exports/customer_export_selected.php b/app/Exports/customer_export_selected.php new file mode 100644 index 0000000..4643cbc --- /dev/null +++ b/app/Exports/customer_export_selected.php @@ -0,0 +1,68 @@ +ids = explode(',', $ids); // Ensure ids are split into an array + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + // Log the ids for debugging purposes + Log::info('Fetching data for IDs: ' . implode(',', $this->ids)); + + $selected_customer = IamPrincipal::whereIn('id', $this->ids) + ->with('state:id,name') // Eager load the state relationship + ->orderBy('id', 'desc') + ->select( + 'first_name', + 'last_name', + 'email_address', + 'date_of_birth', + 'state_xid', + 'phone_number' + ) + ->get() + ->map(function ($customer) { + return [ + 'first_name' => $customer->first_name, + 'last_name' => $customer->last_name, + 'email_address' => $customer->email_address, + 'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), // Format the date + 'state_xid' => $customer->state->name ?? '', // Access the state name and handle null + 'phone_number' => $customer->phone_number, + ]; + }); + + // Log the fetched data for debugging purposes + Log::info('Fetched customer data: ' . $selected_customer->toJson()); + + return new Collection($selected_customer); + } + + public function headings(): array + { + return [ + 'First Name', + 'Last Name', + 'Email Address', + 'Date of Birth', + 'State Name', + 'Phone Number' + ]; + } +} diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php index 174edb5..3ee8478 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php @@ -269,4 +269,20 @@ class AuthController extends Controller return response()->json(__('something_went_wrong'), 500); } } + + /** + * Created By : Sayli Raut + * Created at : 19 June 2024 + * Use : Search State. + */ + public function searchState(Request $request) + { + try { + return $this->AuthServices->searchState($request); + } catch (\Exception $ex) { + Log::error("Login API Failed: " . $ex->getMessage()); + return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500); + } + } + } diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php b/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php new file mode 100644 index 0000000..20fe50c --- /dev/null +++ b/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php @@ -0,0 +1,86 @@ +FeedbackApiServices = $FeedbackApiServices; + } + + /** + * Created By : Sayli Raut + * Created at : 07 June 2024 + * Use : Storing feedback. + */ + + public function getFeedbackReaction(Request $request) + { + try { + $token = readHeaderToken(); + if ($token) { + + $feedbackReactions = FeedbackReaction::select('id', 'feedback_reaction_title')->get(); + + if ($feedbackReactions->isEmpty()) { + Log::info('Reactions not found.'); + return jsonResponseWithSuccessMessageApi(__('success.data_not_found'), [], 200); + } + + $responseData['result'] = $feedbackReactions; + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $feedbackReactions, 200); + } else { + return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + } + } catch (Exception $e) { + Log::error('Feedback Reaction API failed: ' . $e); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + + public function storeFeedback(Request $request) + { + try { + $token = readHeaderToken(); + $validator = Validator::make($request->all(), [ + 'reaction' => 'required|numeric', + 'is_app_feedback' => 'required|boolean', + 'is_restaurant_feedback' => 'required|boolean', + 'restaurant_id' => $request->input('is_restaurant_feedback') == 1 ? 'required|integer' : '', + // 'comment' => 'required', + ]); + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + Log::error("Validation error: " . implode(", ", $validationErrors)); + return jsonResponseWithErrorMessageApi($validationErrors, 403); + } + + if ($token) { + $customerIamId = $token['sub']; + $response = $this->FeedbackApiServices->storeFeedback($customerIamId, $request); + return $response; + } 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/Admin/APIs/Customer_API/RestaurantControllerApi.php b/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php index c2d08c2..31e8e2d 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php @@ -171,7 +171,7 @@ class RestaurantControllerApi extends Controller } } - /** + /** * Created By : Sayli Raut * Created at : 04 June 2024 * Use : To redeem restaurant. @@ -198,4 +198,26 @@ class RestaurantControllerApi extends Controller return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } + + + /** + * Created By : Sayli Raut + * Created at : 20 June 2024 + * Use : To search from restaurant. + */ + public function searchRestaurant(Request $request) + { + try { + $token = readHeaderToken(); + if ($token) { + $customerIamId = $token['sub']; + return $this->RestaurantApiServices->searchRestaurant($customerIamId, $request); + } 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/Admin/APIs/Customer_API/RulesControllerAPI.php b/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php new file mode 100644 index 0000000..fa1f244 --- /dev/null +++ b/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php @@ -0,0 +1,41 @@ +RulesApiServices = $RulesApiServices; + } + + /** + * Created By : sayli Raut + * Created at : 19 June 2024 + * Use : To get voucher rules and regulation. + */ + public function getVoucherRules() + { + try { + $token = readHeaderToken(); + if ($token) { + $customerIamId = $token['sub']; + $response = $this->RulesApiServices->getVoucherRules(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + } else { + return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + } + } catch (\Exception $e) { + Log::error('Voucher rules get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } +} diff --git a/app/Http/Controllers/Admin/APIs/RestaurantApi/RedeemControllerApi.php b/app/Http/Controllers/Admin/APIs/RestaurantApi/RedeemControllerApi.php new file mode 100644 index 0000000..102de31 --- /dev/null +++ b/app/Http/Controllers/Admin/APIs/RestaurantApi/RedeemControllerApi.php @@ -0,0 +1,86 @@ +RedeemApiService = $RedeemApiService; + } + + /** + * Created By : sayli Raut + * Created at : 11 June 2024 + * Use : To get redeem voucher/restaurant. + */ + public function getRedemedData() + { + try { + $token = readRestHeaderToken(); + if ($token) { + $restIamId = $token['sub']; + return $this->RedeemApiService->getRedemedData($restIamId); + } 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); + } + } + + public function undoRedemption(Request $request) + { + try { + $token = readRestHeaderToken(); + if ($token) { + $restIamId = $token['sub']; + $validator = Validator::make($request->all(), [ + 'voucher_id' => 'required', + ]); + + if ($validator->fails()) { + return jsonResponseWithErrorMessageApi($validator->errors()->first(), 400); + } + + return $this->RedeemApiService->undoRedemption($restIamId, $request); + } 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); + } + } + + /** + * Created By : sayli Raut + * Created at : 11 June 2024 + * Use : Search Redemption coupon. + */ + public function searchRedemption(Request $request) + { + try { + $token = readRestHeaderToken(); + if ($token) { + $restIamId = $token['sub']; + return $this->RedeemApiService->searchRedemption($restIamId, $request); + } 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/Admin/APIs/RestaurantApi/RestAuthApiController.php b/app/Http/Controllers/Admin/APIs/RestaurantApi/RestAuthApiController.php index 00ee987..7bf8dbd 100644 --- a/app/Http/Controllers/Admin/APIs/RestaurantApi/RestAuthApiController.php +++ b/app/Http/Controllers/Admin/APIs/RestaurantApi/RestAuthApiController.php @@ -1,6 +1,7 @@ RestAuthApiService = $RestAuthApiService; - } + } /** * Created By : sayali parab @@ -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. @@ -63,7 +64,7 @@ class RestAuthApiController extends Controller 'last_name' => 'required|string|min:2|max:100', 'role' => 'required|string|min:2|max:100', 'restaurant_xid' => 'required', - 'state_xid'=>'required', + // 'state_xid'=>'required', 'date_of_birth' => 'required|date', 'email_address' => [ 'required', @@ -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); + } + } + + + } diff --git a/app/Http/Controllers/Admin/APIs/RestaurantApi/RestaurantControllerApi.php b/app/Http/Controllers/Admin/APIs/RestaurantApi/RestaurantControllerApi.php index 838a6ce..4ddb6f4 100644 --- a/app/Http/Controllers/Admin/APIs/RestaurantApi/RestaurantControllerApi.php +++ b/app/Http/Controllers/Admin/APIs/RestaurantApi/RestaurantControllerApi.php @@ -95,6 +95,7 @@ class RestaurantControllerApi extends Controller $restIamId = $token['sub']; $validator = Validator::make($request->all(), [ 'name' => 'required', + 'phone_number' => 'required', 'address' => 'required', 'bio' => 'required', 'try_on_1' => 'required', diff --git a/app/Http/Controllers/Admin/AboutUsController.php b/app/Http/Controllers/Admin/AboutUsController.php index 7e23404..ccfbd2a 100644 --- a/app/Http/Controllers/Admin/AboutUsController.php +++ b/app/Http/Controllers/Admin/AboutUsController.php @@ -39,8 +39,10 @@ class AboutUsController extends Controller public function edit($id) { - $edit_privacy_policy = Aboutus::find($id)->toArray(); - return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_cust', compact('edit_privacy_policy')); + $edit_aboutUs_cust = Aboutus::find($id)->toArray(); + // dd($edit_privacy_policy); + return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_cust', compact('edit_aboutUs_cust')); + } @@ -165,6 +167,7 @@ class AboutUsController extends Controller DB::beginTransaction(); if (isset($request->about_image)) { + $image = $request->about_image; $image_db = null; } else { @@ -191,4 +194,40 @@ class AboutUsController extends Controller return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } + + + //new update customer aboutUs + /** + * Created By : sayali parab + * Created at : 11 May 2024 + * Use : To update customer about us page. + */ + public function update_aboutUS_Cust(Request $request) + { + $update = Aboutus::find($request->about_custom_id); + $update->description = $request->input('about_us'); + // dd( $update); + $update->save(); + return response()->json(['success' => true, 'status' => 200]); + } + + + //new update restatuant aboutUs + + + /** + * Created By : sayali parab + * Created at : 11 May 2024 + * Use : To update resturant about us page. + */ + public function update_aboutUS_Rest(Request $request) + { + $update_rest = Aboutus::find($request->about_rest_id); + $update_rest->description = $request->input('about_rest'); + // dd($update_rest); + $update_rest->save(); + return response()->json(['success' => true, 'status' => 200]); + } + + } diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index c157cb6..e311f29 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -11,7 +11,7 @@ use App\Models\ManageRestaurant; class DashboardController extends Controller { - /** + /** * Created By : sayali parab * Created at : 16 May 2024 * Use : To show the dashboard. @@ -19,145 +19,78 @@ class DashboardController extends Controller // public function showDashboard(){ - + // return view('Admin.dashboard'); // } public function showDashboard() { - - - // Fetching data for sorting by day - // $dailyData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("DATE(created_at) as date")) - // ->whereBetween('created_at', [now()->subDays(7), now()]) // Fetch data for the last 7 days - // ->groupBy(DB::raw("DATE(created_at)")) - // ->orderBy(DB::raw("DATE(created_at)")) - // ->pluck('count', 'date') - // ->toArray(); - - // Ensure that $dailyData contains zeros for days with no data - $start_date = now()->subDays(7)->startOfDay(); - $end_date = now()->endOfDay(); - $formattedDailyData = []; - while ($start_date <= $end_date) { - $formattedDailyData[$start_date->format('Y-m-d')] = isset($dailyData[$start_date->format('Y-m-d')]) ? $dailyData[$start_date->format('Y-m-d')] : 0; - $start_date->addDay(); - } - - // Default sales chart data (monthly) - // $defaultData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - // ->whereYear('created_at', date('Y')) - // ->groupBy(DB::raw("MONTH(created_at)")) - // ->orderBy(DB::raw("MONTH(created_at)")) - // ->pluck('count', 'month') - // ->toArray(); - - // Ensure that $defaultData contains zeros for months with no data - $months = range(1, 12); - $formattedDefaultData = []; - foreach ($months as $month) { - $formattedDefaultData[$month] = isset($defaultData[$month]) ? $defaultData[$month] : 0; - } - - // $quarterlyData = OrderedPassport::select( - // DB::raw("COUNT(*) as count"), - // DB::raw("QUARTER(created_at) as quarter") - // ) - // ->whereYear('created_at', date('Y')) - // ->groupBy(DB::raw("QUARTER(created_at)")) - // ->orderBy(DB::raw("QUARTER(created_at)")) - // ->pluck('count', 'quarter') - // ->toArray(); - - // Ensure that $quarterlyData contains zeros for quarters with no data - for ($i = 1; $i <= 4; $i++) { - if (!isset($quarterlyData[$i])) { - $quarterlyData[$i] = 0; - } - } - - // Fetching data for yearly option - // $yearlyData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - // ->groupBy(DB::raw("YEAR(created_at)")) - // ->pluck('count', 'year') - // ->toArray(); - // // Monthly data $dataMonthlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - ->whereIn('principal_type_xid', [3]) + ->where('principal_type_xid', 3) ->whereYear('created_at', date('Y')) ->groupBy(DB::raw("MONTH(created_at)")) ->orderBy(DB::raw("MONTH(created_at)")) ->pluck('count', 'month') ->toArray(); - // dd($dataMonthlyWithType3); - // return $dataMonthlyWithType3; $dataMonthlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - ->whereIn('principal_type_xid', [4]) + ->where('principal_type_xid', 4) ->whereYear('created_at', date('Y')) ->groupBy(DB::raw("MONTH(created_at)")) ->orderBy(DB::raw("MONTH(created_at)")) ->pluck('count', 'month') ->toArray(); - // Quarterly data - $dataQuarterlyWithType3 = IamPrincipal::select( - DB::raw("COUNT(*) as count"), - DB::raw("QUARTER(created_at) as quarter") - ) - ->whereIn('principal_type_xid', [3]) - ->groupBy(DB::raw("QUARTER(created_at)")) - ->orderBy(DB::raw("QUARTER(created_at)")) - ->pluck('count', 'quarter') - ->toArray(); - for ($i = 1; $i <= 4; $i++) { - if (!isset($dataQuarterlyWithType3[$i])) { - $dataQuarterlyWithType3[$i] = 0; - } - } + // Fill missing months with zeros + $months = range(1, 12); + $dataMonthlyWithType3 = array_replace(array_fill_keys($months, 0), $dataMonthlyWithType3); + $dataMonthlyWithType4 = array_replace(array_fill_keys($months, 0), $dataMonthlyWithType4); - $dataQuarterlyWithType4 = IamPrincipal::select( - DB::raw("COUNT(*) as count"), - DB::raw("QUARTER(created_at) as quarter") - ) - ->whereIn('principal_type_xid', [4]) + // Quarterly data + $dataQuarterlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter")) + ->where('principal_type_xid', 3) ->groupBy(DB::raw("QUARTER(created_at)")) ->orderBy(DB::raw("QUARTER(created_at)")) ->pluck('count', 'quarter') ->toArray(); - for ($i = 1; $i <= 4; $i++) { - if (!isset($dataQuarterlyWithType4[$i])) { - $dataQuarterlyWithType4[$i] = 0; - } - } + + $dataQuarterlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter")) + ->where('principal_type_xid', 4) + ->groupBy(DB::raw("QUARTER(created_at)")) + ->orderBy(DB::raw("QUARTER(created_at)")) + ->pluck('count', 'quarter') + ->toArray(); + + // Fill missing quarters with zeros + $quarters = range(1, 4); + $dataQuarterlyWithType3 = array_replace(array_fill_keys($quarters, 0), $dataQuarterlyWithType3); + $dataQuarterlyWithType4 = array_replace(array_fill_keys($quarters, 0), $dataQuarterlyWithType4); // Yearly data $dataYearlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - ->whereIn('principal_type_xid', [3]) + ->where('principal_type_xid', 3) ->groupBy(DB::raw("YEAR(created_at)")) ->pluck('count', 'year') ->toArray(); - // dd($dataYearlyWithType3); $dataYearlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - ->whereIn('principal_type_xid', [4]) + ->where('principal_type_xid', 4) ->groupBy(DB::raw("YEAR(created_at)")) ->pluck('count', 'year') ->toArray(); - $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); - // $activePassports = ManagePassport::where('is_active', 1)->take(12)->get(); - // $restaurantCount = ManageRestaurant::where('is_redeem', 1)->count(); $restaurantCount = ManageRestaurant::where('is_active', 1)->count(); - // $recent_transaction = OrderedPassport::with('order', 'order_passport', 'carts.passport', 'iamPrincipal')->get()->toArray(); - // $datas = MyPassportVoucher::with('passportVouchers', 'passportData', 'customer')->get()->toArray(); - - // Pass the data to the view - // return view('Admin.dashboard', compact('customerCount', 'activePassports', 'restaurantCount', 'recent_transaction', 'datas', 'formattedDefaultData', 'quarterlyData', 'yearlyData', 'dataMonthlyWithType3', 'dataMonthlyWithType4', 'dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4','formattedDailyData')); - return view('Admin.dashboard', compact('customerCount','restaurantCount','dataMonthlyWithType3','dataMonthlyWithType4','dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4','formattedDefaultData','quarterlyData')); - + return view('Admin.dashboard', compact( + 'customerCount', + 'restaurantCount', + 'dataMonthlyWithType3', + 'dataMonthlyWithType4', + 'dataQuarterlyWithType3', + 'dataQuarterlyWithType4', + 'dataYearlyWithType3', + 'dataYearlyWithType4' + )); } - } diff --git a/app/Http/Controllers/Admin/FaqController.php b/app/Http/Controllers/Admin/FaqController.php index 0cb3774..67478ad 100644 --- a/app/Http/Controllers/Admin/FaqController.php +++ b/app/Http/Controllers/Admin/FaqController.php @@ -30,6 +30,7 @@ class FaqController extends Controller public function index() { $data = $this->faqServices->viewfaq(); + // return $data; return view('Admin.pages.manage_cms.manage_faq.manage_faq')->with($data); } /** diff --git a/app/Http/Controllers/Admin/LoginController.php b/app/Http/Controllers/Admin/LoginController.php index 58f3592..1a34be4 100644 --- a/app/Http/Controllers/Admin/LoginController.php +++ b/app/Http/Controllers/Admin/LoginController.php @@ -39,7 +39,9 @@ class LoginController extends Controller 'password' => 'required|string', ]); - $user = IamPrincipal::where('email_address', $validatedData['email'])->first(); + $user = IamPrincipal::where('email_address', $validatedData['email']) + ->whereIn('principal_type_xid', [1, 2]) + ->first(); if ($user) { if (Hash::check($validatedData['password'], $user->password)) { diff --git a/app/Http/Controllers/Admin/ManageContactUsController.php b/app/Http/Controllers/Admin/ManageContactUsController.php index 95a090b..1bf4633 100644 --- a/app/Http/Controllers/Admin/ManageContactUsController.php +++ b/app/Http/Controllers/Admin/ManageContactUsController.php @@ -8,18 +8,76 @@ use App\Mail\ReplyMail; use App\Models\ManageContactus; use Illuminate\Support\Facades\Mail; + class ManageContactUsController extends Controller -{ /** - * Created By : sayali parab - * Created at : 05 June 2024 - * Use : To get contact us page. - */ - public function index(){ - // $queries = ManageContactUs::latest()->get(); - $queries = ManageContactUs::all(); +{ + /** + * Created By : sayali parab + * Created at : 05 June 2024 + * Use : To get contact us page. + */ + public function index(Request $request) + { + + $isReply = $request->query('is_reply'); + + if ($isReply == 1) { + $queries = ManageContactUs::with('customer')->where('is_reply', 1)->orderBy('id','desc')->get(); + } elseif ($isReply == 0 && $isReply != null) { + $queries = ManageContactUs::with('customer')->where('is_reply', 0)->orderBy('id','desc')->get(); + } else { + $queries = ManageContactUs::with('customer')->orderBy('id','desc')->get(); + } + // return $queries; + return view('Admin.pages.manage_contact_us.manage_contact', compact('queries')); + } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To send reply. + */ + + public function sendReply(Request $request) + { + if (!$request->user_id || $request->user_id == null) { + return response()->json(['error' => 'User not found'], 404); + } + $userId = $request->user_id; + + $query = ManageContactus::find($userId); + if (!$query) { + return response()->json(['error' => 'Query not found'], 404); + } + + $request->validate([ + 'reply_message' => 'required|string', + ]); + + $query->reply_message = $request->input('reply_message'); + $query->is_reply = true; + $query->save(); + + try { + Mail::to($query->email)->send(new \App\Mail\ReplyMail($query)); + } catch (\Exception $e) { + return response()->json(['error' => 'Failed to send email', 'message' => $e->getMessage()], 500); + } + + + return response()->json(['message' => 'Reply sent successfully']); + } + - return view('Admin.pages.manage_contact_us.manage_contact',compact('queries')); - + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To delete query. + */ + public function delete_user($id) + { + $data = ManageContactUs::find($id)->delete(); + return redirect()->back()->with('success', ''); } } diff --git a/app/Http/Controllers/Admin/ManageCustomerController.php b/app/Http/Controllers/Admin/ManageCustomerController.php index 276748a..449f541 100644 --- a/app/Http/Controllers/Admin/ManageCustomerController.php +++ b/app/Http/Controllers/Admin/ManageCustomerController.php @@ -14,8 +14,12 @@ use App\Exports\customer_export; use App\Exports\customer_export_selected; use App\Exports\CustomerExportSelected; use App\Models\ManageRestaurant; +use App\Models\ManageState; use App\Models\RedeemRestaurant; +use Illuminate\Support\Facades\Validator; +use Illuminate\Validation\Rule; use Barryvdh\DomPDF\PDF as DomPDFPDF; +use Carbon\Carbon; use Exception; use PDF; @@ -25,7 +29,7 @@ use PDF; class ManageCustomerController extends Controller { - /* + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Get User Page. @@ -45,7 +49,7 @@ class ManageCustomerController extends Controller return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } -/* + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Get Passport Page. @@ -55,14 +59,18 @@ class ManageCustomerController extends Controller try { - $customers_data = IamPrincipal::findOrFail($id); + $customers_data = IamPrincipal::with('state', 'contactMessages')->findOrFail($id); + if ($customers_data->contactMessages->isEmpty()) { + Log::info('No contact messages found for customer with ID: ' . $id); + } + // return $customers_data; return view('Admin.pages.manage_users.manage_customer.view_customer_details', compact('customers_data')); } catch (Exception $e) { Log::error("Manage Voucher Page Not Load " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } -/* + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Get Customer data. @@ -72,31 +80,74 @@ class ManageCustomerController extends Controller { try { - $customers_data = IamPrincipal::findOrFail($id); - return view('Admin.pages.manage_users.manage_customer.edit_customer', compact('customers_data')); + $customers_data = IamPrincipal::with('state')->findOrFail($id); + $state = ManageState::where('is_active', 1)->get(); + return view('Admin.pages.manage_users.manage_customer.edit_customer', compact('customers_data', 'state')); } catch (Exception $e) { Log::error("Manage Voucher Page Not Load " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } - /* + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Update Customer Form. */ + public function update(Request $request) { + // Validation rules + $rules = [ + 'email_address' => [ + 'required', + 'string', + 'email', + 'max:100', + Rule::unique('iam_principal')->where(function ($query) use ($request) { + return $query->where('principal_type_xid', 3) + ->whereNull('deleted_at') + ->where('id', '!=', $request->customer_id); + }), + ], + 'date_of_birth' => [ + 'required', + 'date', + function ($attribute, $value, $fail) { + $dob = Carbon::parse($value); + $age = $dob->age; + if ($age < 21) { + $fail('You must be at least 21 years old.'); + } + }, + ], + ]; + $messages = [ + 'email_address.required' => 'Enter email address', + 'email_address.email' => 'Please enter a valid email address', + 'email_address.unique' => 'This email is already registered', + 'date_of_birth.required' => 'Date of Birth is required', + 'date_of_birth.date' => 'Please enter a valid date', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->errors()], 422); + } try { DB::beginTransaction(); + $customer_data = IamPrincipal::where('id', $request->customer_id)->first(); $customer_data->first_name = $request->input('name'); $customer_data->last_name = $request->input('last_name'); - $customer_data->phone_number = $request->input('phone'); - $customer_data->email_address = $request->input('email_id'); + $customer_data->email_address = $request->input('email_address'); + $customer_data->date_of_birth = $request->input('date_of_birth'); + $customer_data->state_xid = $request->input('state_xid'); $customer_data->save(); + DB::commit(); return jsonResponseWithSuccessMessage(__('success.update_data')); @@ -150,7 +201,7 @@ class ManageCustomerController extends Controller return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); } } - /* + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Get pdf. @@ -171,26 +222,44 @@ class ManageCustomerController extends Controller } } + /* + Created By : Sayali Parab + Created at : 28 May 2024 + Use : To Get Excel. + */ - // public function exportSelectedCustomer(Request $request) - // { + public function exportSelectedCustomer(Request $request) + { + try { + if ($request->has('all_id')) { + return Excel::download(new customer_export, 'Passport_data.xlsx'); + } - // try { + $ids = $request->selected_id; - // if ($request->has('all_id')) { - // return Excel::download(new customer_export, 'Passport_data.xlsx'); - // } + if (empty($ids)) { + return response()->json(['error' => 'No IDs provided for export.'], 400); + } - // $ids = $request->selected_id; + Log::info("Selected IDs for export: " . $ids); - // $fileName = 'selected_customer_data.xlsx'; - // return Excel::download(new customer_export_selected($ids), $fileName); - // } catch (\Exception $e) { - // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); - // } - // } + $fileName = 'selected_customer_data.xlsx'; - /* + Log::info("Attempting to export selected customers to file: " . $fileName); + + return Excel::download(new customer_export_selected($ids), $fileName); + } catch (\Exception $e) { + Log::error('Export failed: ' . $e->getMessage()); + return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + } + } + + + + + + + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Deleted Data Restore. @@ -222,10 +291,33 @@ class ManageCustomerController extends Controller { try { $redeemDetails = RedeemRestaurant::with('restaurant', 'customer')->where('iam_principal_xid', $id)->get(); + // return $redeemDetails; return view('Admin.pages.manage_users.manage_customer.customer_restaurants', compact('redeemDetails')); } catch (Exception $e) { Log::error("Error getting restaurant details: " . $e->getMessage()); return response()->json(['error' => __('auth.something_went_wrong')], 500); } } + + /* + Created By : Sayali parab + Created at : 27 June 2024 + Use : To delete customer details. + */ + + public function deleteCustomerUser($id) + { + try { + DB::beginTransaction(); + $deleteCustomer = IamPrincipal::find($id); + // dd($id ); + $deleteCustomer->delete(); + DB::commit(); + return response()->json(['sucess' => true, 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("delete_passport function Load Failed " . $e->getMessage()); + return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); + } + } } diff --git a/app/Http/Controllers/Admin/ManageFeedbackController.php b/app/Http/Controllers/Admin/ManageFeedbackController.php index 0005933..c77ad86 100644 --- a/app/Http/Controllers/Admin/ManageFeedbackController.php +++ b/app/Http/Controllers/Admin/ManageFeedbackController.php @@ -2,20 +2,57 @@ namespace App\Http\Controllers\Admin; +use App\Exports\FeedbakExport; use App\Http\Controllers\Controller; +use App\Models\ManageFeedback; use Illuminate\Http\Request; +use Maatwebsite\Excel\Facades\Excel; + class ManageFeedbackController extends Controller { - /** - * Created By : sayali parab - * Created at : 17 May 2024 - * Use : To get manage feedback page. - */ - public function index(){ - - return view('Admin.pages.manage_feedback.manage_feedback'); + /** + * Created By : sayali parab + * Created at : 17 May 2024 + * Use : To get manage feedback page. + */ + public function index() + { + $feedback = ManageFeedback::with('principal', 'feedbackReaction','restaurant') + ->orderBy('created_at', 'desc') + ->get(); + return view('Admin.pages.manage_feedback.manage_feedback', compact('feedback')); + } + + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To delete query. + */ + public function delete_feedback($id) + { + $data = ManageFeedback::find($id)->delete(); + return redirect()->back()->with('success', ''); + } + + /* + Created By : Sayli Raut + Created at : 17 June 2024 + Use : To download Excel. + */ + public function exportSelectedFeedback(Request $request) + { + // dd($request->all()); + try { + if ($request->has('all_id')) { + return Excel::download(new FeedbakExport, 'Feedback_data.xlsx'); + } + + } catch (\Exception $e) { + return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + } } } diff --git a/app/Http/Controllers/Admin/ManageLocationController.php b/app/Http/Controllers/Admin/ManageLocationController.php new file mode 100644 index 0000000..8d730d4 --- /dev/null +++ b/app/Http/Controllers/Admin/ManageLocationController.php @@ -0,0 +1,136 @@ +get(); + return view('Admin.pages.manage_states.manage_states', compact('location')); + } + /* + Created By : Sayali parab + Created at : 07 June 2024 + Use : To store the location. + */ + + + public function store(Request $request) + { + $request->validate([ + 'location_name' => 'required|string|max:255' + ]); + + try { + if (ManageState::where('name', $request->location_name)->exists()) { + return response()->json(['success' => false, 'error' => 'Location name already exists', 'status' => 422]); + } + + + $location = new ManageState(); + $location->name = $request->location_name; + $location->save(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (\Exception $e) { + return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); + } + } + + + /* + Created By : Sayali parab + Created at : 07 June 2024 + Use : To change status. + */ + public function change_location_status(Request $request) + { + + try { + DB::beginTransaction(); + $status = ManageState::find($request->location_id); + $status->is_active = $request->status; + $status->save(); + // return response()->json(['status' => 200]); + DB::commit(); + + return jsonResponseWithSuccessMessage(__('success.update_data')); + } catch (Exception $e) { + Log::error("Update Status function Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + + + /* + Created By : Sayali parab + Created at : 07 June 2024 + Use : To delete location. + */ + public function delete_location($id) + { + + + try { + DB::beginTransaction(); + + $passport = ManageState::find($id); + $passport->delete(); + + DB::commit(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("delete_location function Load Failed " . $e->getMessage()); + return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); + } + } + + + /* + Created By : Sayali parab + Created at : 07 June 2024 + Use : To update location. + */ + + public function update(Request $request) + { + try { + DB::beginTransaction(); + + // Check if the location name already exists, excluding the current location + if (ManageState::where('name', $request->location_name)->where('id', '!=', $request->id)->exists()) { + return response()->json(['success' => false, 'error' => 'Location name already exists', 'status' => 422]); + } + + $location_data = ManageState::find($request->id); + $location_data->name = $request->location_name; + $location_data->save(); + + DB::commit(); + + return response()->json(['success' => true, 'message' => __('success.update_data'), 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("Failed to update location: " . $e->getMessage()); + return response()->json(['success' => false, 'error' => __('auth.something_went_wrong'), 'status' => 500]); + } + } + + +} diff --git a/app/Http/Controllers/Admin/ManageNewsAndArticlesController.php b/app/Http/Controllers/Admin/ManageNewsAndArticlesController.php index cd6cc86..2e23abc 100644 --- a/app/Http/Controllers/Admin/ManageNewsAndArticlesController.php +++ b/app/Http/Controllers/Admin/ManageNewsAndArticlesController.php @@ -1,6 +1,7 @@ latest()->get()->toArray(); return view('Admin.pages.manage_cms.manage_new.manage_news', compact('news_article')); @@ -31,17 +32,16 @@ class ManageNewsAndArticlesController extends Controller Log::error("Manage Article Page Not Load: " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } - } -/** - * Created By : sayali parab - * Created at : 27 May 2024 - * Use : To change status. - */ + /** + * Created By : sayali parab + * Created at : 27 May 2024 + * Use : To change status. + */ public function change_news_article_Status(Request $request) { - + try { $status = NewsArticle::find($request->program_id); @@ -60,223 +60,132 @@ class ManageNewsAndArticlesController extends Controller } } -/** - * Created By : sayali parab - * Created at : 27 May 2024 - * Use : To edit. - */ + /** + * Created By : sayali parab + * Created at : 27 May 2024 + * Use : To edit. + */ public function edit($id) { - + try { $news_article_data = NewsArticle::find($id); $news_categories = NewsArticleCategory::all()->toArray(); - return view('Admin.pages.manage_cms.manage_new.manage_news_edit', compact('news_article_data','news_categories')); + return view('Admin.pages.manage_cms.manage_new.manage_news_edit', compact('news_article_data', 'news_categories')); } catch (\Exception $e) { // Handle the exception, you can log it or return an error response return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); } } - // public function update(Request $request) - // { - // try { - - // $update_news_article = NewsArticle::find($request->article_id); - // $update_news_article->name = $request->input('article_name'); - // // dd( $update_news_article->name); - // $update_news_article->description = $request->input('article_dis'); - // // dd($update_news_article->description); - - // // if ($request->hasFile('article_image')) { - // // if ($update_news_article->image) { - // // Storage::disk('public')->delete($update_news_article->image); - // // } - - // // $uploadedFile = $request->file('article_image'); - // // $extension = $uploadedFile->getClientOriginalExtension(); - // // $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); - // // $path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public'); - // // $update_news_article->image = $path; - // // } - - // if ($request->hasFile('article_thmb')) { - // if ($update_news_article->image) { - // Storage::disk('public')->delete($update_news_article->thumbnail_image); - // } - - // $uploadedFile = $request->file('article_thmb'); - // $extension = $uploadedFile->getClientOriginalExtension(); - // $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); - // $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public'); - // $update_news_article->thumbnail_image = $path; - // } - - // $update_news_article->save(); - // // dd( $update_news_article); - // return response()->json(['success' => true,'status'=>200]); - // } catch (\Exception $e) { - // return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); - // } - // } /** - * Created By : sayali parab - * Created at : 27 May 2024 - * Use : To update. - */ + * Created By : sayali parab + * Created at : 27 May 2024 + * Use : To update. + */ public function update(Request $request) -{ - try { - $update_news_article = NewsArticle::find($request->article_id); - $update_news_article->name = $request->input('article_name'); - $update_news_article->description = $request->input('article_dis'); - - - - - if ($request->hasFile('article_thmb')) { - if ($update_news_article->image) { - Storage::disk('public')->delete($update_news_article->thumbnail_image); - } - - $uploadedFile = $request->file('article_thmb'); - $extension = $uploadedFile->getClientOriginalExtension(); - $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); - $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public'); - $update_news_article->thumbnail_image = $path; - } - - $update_news_article->save(); - - return response()->json(['success' => true, 'status' => 200]); - } catch (\Exception $e) { - return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); - } -} -/** - * Created By : sayali parab - * Created at : 28 May 2024 - * Use : To delete. - */ -public function delete_newsarticle($id) -{ - - try { - $blog = NewsArticle::find($id); - - if (!$blog) { - return response()->json(['error' => 'Aboutus entry not found.'], 404); - } - - $blog->delete(); - - return response()->json(['success' => 'Aboutus entry deleted successfully.']); - } catch (\Exception $e) { - // Log the exception or handle it in a way that makes sense for your application - return response()->json(['error' => 'An error occurred while deleting the Aboutus entry.'], 500); - } - -} - -/** - * Created By : sayali parab - * Created at : 28 May 2024 - * Use : To add. - */ - public function add() - { - $news_categories = NewsArticleCategory::all()->toArray(); - return view('Admin.pages.manage_cms.manage_new.manage_news_add', compact('news_categories')); - } - - // public function insert(Request $request) - // { - - // try { - // $blog = new NewsArticle; - // $blog->name = $request->input('article_name'); - // $blog->description = $request->input('article_des'); - // $blog->news_articles_category_xid = $request->input('category'); - - // // if ($request->hasFile('article_image')) { - // // $uploadedFile = $request->file('article_image'); - // // $extension = $uploadedFile->getClientOriginalExtension(); - // // $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); - // // // Move the uploaded file to the storage folder - // // $path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public'); - // // // Store the file path in the database - // // $blog->image = $path; - // // } - // // upload blog single image - // if ($request->hasFile('article_thmb')) { - // $uploadedFile = $request->file('article_thmb'); - // $extension = $uploadedFile->getClientOriginalExtension(); - // $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); - // $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public'); - // $blog->thumbnail_image = $path; - // } - // $blog->save(); - // return response()->json(['success' => true,'status'=>200]); - // } catch (\Exception $e) { - // // Handle the exception, you can log it or return an error response - // return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); - // } - // } - - /** - * Created By : sayali parab - * Created at : 28 May 2024 - * Use : To insert. - */ - public function insert(Request $request) { try { - // Validate the incoming request - // $request->validate([ - // // 'article_name' => 'required|string', - // // 'article_des' => 'required|string', - // 'article_thmb' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', - // 'category' => 'required|string', // Assuming 'category' is the field for category selection - // ]); - - DB::beginTransaction(); - - // Handle thumbnail image upload + $update_news_article = NewsArticle::find($request->article_id); + $update_news_article->name = $request->input('article_name'); + $update_news_article->description = $request->input('article_dis'); + $update_news_article->news_articles_category_xid = $request->input('category_xid'); + if ($request->hasFile('article_thmb')) { + if ($update_news_article->image) { + Storage::disk('public')->delete($update_news_article->thumbnail_image); + } + $uploadedFile = $request->file('article_thmb'); + $extension = $uploadedFile->getClientOriginalExtension(); $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public'); + $update_news_article->thumbnail_image = $path; } - - // Create a new instance of NewsArticle model and populate it with data - $blog = NewsArticle::create([ - 'name' => $request->input('article_name'), - 'description' => $request->input('article_des'), - 'news_articles_category_xid' => $request->input('category'), - 'thumbnail_image' => $path // Set thumbnail image path - ]); - // dd( $blog); - - DB::commit(); - - return response()->json([ - 'success' => true, - 'status' => 200, - 'message' => 'News article added successfully', - ]); - } catch (\Exception $exception) { - DB::rollBack(); - // Log the exception for further analysis - Log::error('Error in insert method: ' . $exception->getMessage() . ' at ' . $exception->getFile() . ':' . $exception->getLine()); - - // Return an error response - return response()->json(['error' => 'Failed to add news article'], 500); + + $update_news_article->save(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (\Exception $e) { + return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); } } - + /** + * Created By : sayali parab + * Created at : 28 May 2024 + * Use : To delete. + */ + public function delete_newsarticle($id) + { + + try { + $blog = NewsArticle::find($id); + + if (!$blog) { + return response()->json(['error' => 'Aboutus entry not found.'], 404); + } + + $blog->delete(); + + return response()->json(['success' => 'Aboutus entry deleted successfully.']); + } catch (\Exception $e) { + // Log the exception or handle it in a way that makes sense for your application + return response()->json(['error' => 'An error occurred while deleting the Aboutus entry.'], 500); + } + } + + /** + * Created By : sayali parab + * Created at : 28 May 2024 + * Use : To add. + */ + public function add() + { + $news_categories = NewsArticleCategory::all()->toArray(); + return view('Admin.pages.manage_cms.manage_new.manage_news_add', compact('news_categories')); + } + /** + * Created By : sayali parab + * Created at : 28 May 2024 + * Use : To insert. + */ + + + + + public function insert(Request $request) + { + + try { + $blog = new NewsArticle; + $blog->name = $request->input('article_name'); + $blog->description = $request->input('article_des'); + $blog->news_articles_category_xid = $request->input('category'); + + if ($request->hasFile('article_image')) { + $uploadedFile = $request->file('article_image'); + $extension = $uploadedFile->getClientOriginalExtension(); + $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); + $path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public'); + $blog->image = $path; + } + if ($request->hasFile('article_thmb')) { + $uploadedFile = $request->file('article_thmb'); + $extension = $uploadedFile->getClientOriginalExtension(); + $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName()); + $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public'); + $blog->thumbnail_image = $path; + } + $blog->save(); + return response()->json(['success' => true, 'status' => 200]); + } catch (\Exception $e) { + // Handle the exception, you can log it or return an error response + return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); + } + } } diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index 5518289..cf1a2ad 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -3,13 +3,167 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\IamPrincipal; +use App\Models\NotificationDetails; use Illuminate\Http\Request; +use Exception; +use Illuminate\Support\Facades\Log; +use App\Helpers\onesignalhelper; +use App\Models\ManageState; +use Illuminate\Support\Facades\DB; class ManageNotificationsController extends Controller { - public function index(){ - - return view('Admin.pages.manage_notification.manage_notification'); + public function index(Request $request) + { + /** + * Created By : Sayli Raut + * Created at : 11 June 2024 + * Use : To list notifications. + */ + $activeQuery = $request->query('active'); + if ($activeQuery == 4) { // for customer + $notifications = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 3); + }) + ->latest() + ->take(12) + ->get(); + } else if ($activeQuery == 3) { // for restaurant + $notifications = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 4); + }) + ->latest() + ->take(12) + ->get(); + + // return $notifications; + } else { + $notificationsOfType3 = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 3); + }) + ->latest() + ->take(12) + ->get(); + + $notificationsOfType4 = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 4); + }) + ->latest() + ->take(12) + ->get(); + + $notifications = $notificationsOfType3->merge($notificationsOfType4); + } + + return view('Admin.pages.manage_notification.manage_notification', compact('notifications')); + } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To view notification details.s + */ + public function add() + { + $state = ManageState::where('is_active', 1)->get()->toArray(); + return view('Admin.pages.manage_notification.manage_notifications_add', compact('state')); + } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To add notification . + */ + public function store_notificaton_data(Request $request) +{ + try { + $request->validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', + ]); + + DB::beginTransaction(); + + 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); + + // Fetch OneSignal IDs based on the selected states and user type + $states = $request->states; + + $userQuery = IamPrincipal::where('is_active', 1) + ->where('notification_status', 1) + ->where('principal_type_xid', 3) + ->whereIn('state_xid', $states); + + + if ($request->user_type == 1) { + $allCustomerOneSignalIds = $userQuery->pluck('id'); + $UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get(); + + foreach ($UserData as $customerIdItem) { + 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) { + $allRestaurantOneSignalIds = $userQuery->pluck('id'); + $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); + + foreach ($restaurantData as $restIdItem) { + if ($restIdItem->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $restIdItem->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($restIdItem->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); + } +} + + + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To view notification details.s + */ + public function view($id) + { + $notification = NotificationDetails::with('notification')->findOrFail($id); + return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification')); } } diff --git a/app/Http/Controllers/Admin/ManageRestrauntController.php b/app/Http/Controllers/Admin/ManageRestrauntController.php index 91d3040..9782f7e 100644 --- a/app/Http/Controllers/Admin/ManageRestrauntController.php +++ b/app/Http/Controllers/Admin/ManageRestrauntController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers\Admin; +use App\Exports\RestaurantExport; +use App\Exports\RestaurantExportSelected; use App\Http\Controllers\Controller; use App\Models\ManageRestaurant; use App\Models\OperatingHour; @@ -9,7 +11,9 @@ use Illuminate\Http\Request; use Exception; use App\Helpers\onesignalhelper; use App\Models\IamPrincipal; +use App\Models\ManageState; use Illuminate\Support\Facades\Log; +use Maatwebsite\Excel\Facades\Excel; use Illuminate\Support\Facades\DB; class ManageRestrauntController extends Controller @@ -41,7 +45,8 @@ class ManageRestrauntController extends Controller */ public function add() { - return view('Admin.pages.manage_restaurants.add_restaurant'); + $state = ManageState::where('is_active', 1)->get()->toArray(); + return view('Admin.pages.manage_restaurants.add_restaurant', compact('state')); } @@ -66,7 +71,6 @@ class ManageRestrauntController extends Controller // Creating the restaurant $restaurant = new ManageRestaurant(); $restaurant->name = $request->input('name'); - $restaurant->description = $request->input('description'); $restaurant->image = $imagePath; $restaurant->restaurant_id = $request->input('rest_id'); $restaurant->address = $request->input('address'); @@ -74,10 +78,16 @@ class ManageRestrauntController extends Controller $restaurant->latitude = $request->input('latitude'); $restaurant->longtitude = $request->input('longitude'); $restaurant->exclusion = $request->input('exclusion'); + $restaurant->phone_number = $request->input('phone_number'); + $restaurant->state_xid = $request->input('state_xid'); $restaurant->try_on_1 = $request->input('try_on_1'); $restaurant->try_on_2 = $request->input('try_on_2'); $restaurant->try_on_3 = $request->input('try_on_3'); $restaurant->try_on_4 = $request->input('try_on_4'); + $restaurant->time_hours = $request->input('timeHours'); + $restaurant->max_numb_day = $request->input('maxNumbDay'); + $restaurant->max_numb_week = $request->input('maxNumbWeek'); + $restaurant->max_numb_month = $request->input('maxNumbMonth'); $restaurant->save(); foreach ($request->input('operating_hours') as $day => $hours) { @@ -132,13 +142,15 @@ class ManageRestrauntController extends Controller try { $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week'); $restaurantItem = ManageRestaurant::where('id', $id)->first(); + $state = ManageState::where('is_active', 1)->get()->toArray(); $restaurantItem['image'] = ListingImageUrl('restaurant_images', $restaurantItem['image']); return view( 'Admin.pages.manage_restaurants.edit_restaurant', compact( 'restaurantItem', - 'operating_hours' + 'operating_hours', + 'state' ) ); } catch (Exception $e) { @@ -172,6 +184,8 @@ class ManageRestrauntController extends Controller $restaurant->restaurant_id = $request->input('restaurant_id'); $restaurant->address = $request->input('location_name'); $restaurant->exclusion = $request->input('exclusion'); + $restaurant->phone_number = $request->input('phone_number'); + $restaurant->state_xid = $request->input('state_xid'); $restaurant->latitude = $request->input('latitude'); $restaurant->longtitude = $request->input('longitude'); $restaurant->bio = $request->input('bio'); @@ -179,6 +193,10 @@ class ManageRestrauntController extends Controller $restaurant->try_on_2 = $request->input('try_on_2'); $restaurant->try_on_3 = $request->input('try_on_3'); $restaurant->try_on_4 = $request->input('try_on_4'); + $restaurant->time_hours = $request->input('timeHours'); + $restaurant->max_numb_day = $request->input('maxNumbDay'); + $restaurant->max_numb_week = $request->input('maxNumbWeek'); + $restaurant->max_numb_month = $request->input('maxNumbMonth'); $restaurant->save(); foreach ($request->input('operating_hours') as $day => $hours) { @@ -230,7 +248,7 @@ class ManageRestrauntController extends Controller return view('Admin.pages.manage_restaurants.view_restaurant', compact('restaurantItem', 'operating_hours')); } catch (Exception $e) { - Log::error("view Voucher Load Failed " . $e->getMessage()); + Log::error("view Voucher Load Failed" . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } @@ -339,4 +357,25 @@ Use : To Delete Restaurant. return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); } } + + /* + Created By : Sayli Raut + Created at : 17 June 2024 + Use : To download Excel. + */ + public function exportSelectedRestaurant(Request $request) + { + try { + if ($request->has('all_id')) { + return Excel::download(new RestaurantExport, 'Restaurant_data.xlsx'); + } + + $ids = $request->selected_id; + // dd( $ids); + $fileName = 'selected_restaurant_data.xlsx'; + return Excel::download(new RestaurantExportSelected($ids), $fileName); + } catch (\Exception $e) { + return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + } + } } diff --git a/app/Http/Controllers/Admin/ManageRulesController.php b/app/Http/Controllers/Admin/ManageRulesController.php new file mode 100644 index 0000000..a7e1d48 --- /dev/null +++ b/app/Http/Controllers/Admin/ManageRulesController.php @@ -0,0 +1,51 @@ +toArray(); + return view('Admin.pages.manage_rule.manage_rule', compact('data')); + } + + /** + * Created By : sayli Raut + * Created at : 19 June 2024 + * Use : To edit Rules. + */ + public function edit($id) + { + $data = ManageRule::find($id); + return view('Admin.pages.manage_rule.manage_rules_edit', compact('data')); + } + + /** + * Created By : sayli Raut + * Created at : 19 June 2024 + * Use : To update Rules. + */ + public function update(Request $request) + { + $validated = $request->validate([ + + 'article_des_title' => 'required', + 'article_des_message' => 'required', + ]); + $update = ManageRule::find($request->rule_id); + $update->title = $request->input('article_des_title'); + $update->message = $request->input('article_des_message'); + $update->save(); + return response()->json(['success' => true, 'status' => 200]); + } +} diff --git a/app/Http/Controllers/Admin/ManageSubAdminController.php b/app/Http/Controllers/Admin/ManageSubAdminController.php index 7f4dcb8..a7a81ae 100644 --- a/app/Http/Controllers/Admin/ManageSubAdminController.php +++ b/app/Http/Controllers/Admin/ManageSubAdminController.php @@ -45,6 +45,7 @@ class ManageSubAdminController extends Controller $sub_admin = new IamPrincipal(); $sub_admin->first_name = $request->input('sub_admin_name'); + $sub_admin->last_name=$request->input('sub_admin_lname'); $sub_admin->user_name = 'sub_admin'; $sub_admin->principal_type_xid = 2; $sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid; @@ -131,6 +132,7 @@ class ManageSubAdminController extends Controller $sub_admin = IamPrincipal::find($request->sub_admin_id); $sub_admin->user_name = 'sub_admin'; $sub_admin->first_name = $request->input('sub_admin_name'); + $sub_admin->last_name = $request->input('sub_admin_lname'); $sub_admin->principal_type_xid = 2; $sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid; $sub_admin->email_address = $request->input('sub_admin_email'); @@ -180,7 +182,12 @@ class ManageSubAdminController extends Controller } } - + public function get_sub_admin_permission(Request $request) + { + $testing_admin_id = $request->id; + $test = ManageModuleLink::where('principal_xid', $testing_admin_id)->get('manage_modules_xid')->toArray(); + return response()->json(['success' => true, 'data' => $test]); + } } diff --git a/app/Http/Controllers/Admin/PrivacyPolicyController.php b/app/Http/Controllers/Admin/PrivacyPolicyController.php index 0f06c2d..bfa7457 100644 --- a/app/Http/Controllers/Admin/PrivacyPolicyController.php +++ b/app/Http/Controllers/Admin/PrivacyPolicyController.php @@ -9,17 +9,7 @@ use App\Models\PrivacyPolicy; class PrivacyPolicyController extends Controller { - // public function index(){ - - // return view('Admin.pages.manage_cms.manage_privacy.manage_privacy'); - // } - // public function index(){ - // $view_privacy_policy = PrivacyPolicy::get()->toArray(); - // // dd($view_privacy_policy); - // return view('Admin.pages.manage_cms.manage_privacy.manage_privacy'); - // } - - /** + /** * Created By : sayali parab * Created at : 29 May 2024 * Use : To get privacy policy page. @@ -34,12 +24,12 @@ class PrivacyPolicyController extends Controller * Created at : 29 May 2024 * Use : To edit. */ - public function edit($id){ + public function edit($id) + { $edit_privacy_policy = PrivacyPolicy::find($id)->toArray(); return view('Admin.pages.manage_cms.manage_privacy.manage_privacy_policy_edit', compact('edit_privacy_policy')); } - /** * Created By : sayali parab * Created at : 29 May 2024 @@ -77,3 +67,4 @@ class PrivacyPolicyController extends Controller } } + diff --git a/app/Http/Controllers/Admin/ReferralCodeController.php b/app/Http/Controllers/Admin/ReferralCodeController.php new file mode 100644 index 0000000..b51233f --- /dev/null +++ b/app/Http/Controllers/Admin/ReferralCodeController.php @@ -0,0 +1,47 @@ +ReferralCodeServices = $ReferralCodeServices; + } + public function CheckReferral(Request $request) + { + try { + $token = readHeaderToken(); + $validator = Validator::make($request->all(), [ + 'referral_code' => 'required', + ]); + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + Log::error("Validation error: " . implode(", ", $validationErrors)); + return jsonResponseWithErrorMessageApi($validationErrors, 403); + } + + if ($token) { + $customerIamId = $token['sub']; + $response = $this->ReferralCodeServices->CheckReferral($customerIamId, $request); + return $response; + } 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/Admin/RestaurantAppController.php b/app/Http/Controllers/Admin/RestaurantAppController.php index 2563a8c..3c79ba7 100644 --- a/app/Http/Controllers/Admin/RestaurantAppController.php +++ b/app/Http/Controllers/Admin/RestaurantAppController.php @@ -76,47 +76,7 @@ class RestaurantAppController extends Controller - // public function change_rest_user_status(Request $request) - // { - - // try { - // DB::beginTransaction(); - // $status = IamPrincipal::find($request->rest_user_id); - // $status->is_active = $request->status; - - // // Generate a random password - // $randomPassword = \Str::random(8); // Adjust the length as per your requirements - - // // Set the password - // $status->password = bcrypt($randomPassword); // Make sure to hash the password - - // $status->save(); - - // if ($request->status == 1) { - // // Fetch user data based on user ID - // $user = IamPrincipal::find($request->rest_user_id); - - // if ($user) { - // // Send email only if user exists - // $data = [ - // 'first_name' => $user->first_name, - // 'last_name' => $user->last_name, - // 'email' => $user->email_address, - // 'password' => $randomPassword, // Pass the random password to the email template - // ]; - - // Mail::to($user->email_address)->send(new RestUserApproval($data)); - // } - // } - - // DB::commit(); - - // return jsonResponseWithSuccessMessage(__('success.update_data')); - // } catch (Exception $e) { - // Log::error("Update Status function Load Failed " . $e->getMessage()); - // return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); - // } - // } + /** * Created By : sayali parab * Created at : 03 June 2024 @@ -205,62 +165,7 @@ class RestaurantAppController extends Controller } } - // public function updateRest(Request $request) - // { - - - // try { - // DB::beginTransaction(); - // $rest_data = IamPrincipal::where('id', $request->rest_id)->first(); - // $rest_data->first_name = $request->input('name'); - // $rest_data->last_name = $request->input('last_name'); - - // $rest_data->phone_number = $request->input('phone'); - // $rest_data->email_address = $request->input('email_id'); - // $rest_data->save(); - // DB::commit(); - - // return jsonResponseWithSuccessMessage(__('success.update_data')); - // } catch (Exception $e) { - // DB::rollBack(); - // Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage()); - // return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); - // } - // } - - // public function updateRest(Request $request) - // { - // try { - // DB::beginTransaction(); - - // $rest_data = IamPrincipal::find($request->input('rest_id')); - // if (!$rest_data) { - // throw new Exception('Restaurant not found.'); - // } - - // $rest_data->first_name = $request->input('restaurant_name'); - // $rest_data->description = $request->input('restaurant_des'); - // $rest_data->phone_number = $request->input('restaurant_phone'); - // $rest_data->email_address = $request->input('restaurant_email'); - // $rest_data->location = $request->input('restaurant_loc'); - // $rest_data->bio = $request->input('restaurant_bio'); - - // if ($request->hasFile('restaurant_image')) { - // $imagePath = $request->file('restaurant_image')->store('images', 'public'); - // $rest_data->image_path = $imagePath; - // } - - // $rest_data->save(); - - // DB::commit(); - // return response()->json(['message' => __('success.update_data')], 200); - // } catch (Exception $e) { - // DB::rollBack(); - // Log::error("Update Restaurant Failed: " . $e->getMessage()); - // return response()->json(['message' => __('auth.something_went_wrong')], 500); - // } - // } - + /** * Created By : sayali parab * Created at : 04 June 2024 diff --git a/app/Http/Controllers/Admin/TermsController.php b/app/Http/Controllers/Admin/TermsController.php index 0ccd18b..50246fe 100644 --- a/app/Http/Controllers/Admin/TermsController.php +++ b/app/Http/Controllers/Admin/TermsController.php @@ -1,6 +1,7 @@ toArray(); - return view('Admin.pages.manage_cms.manage_terms.manage_terms',compact('terms_condition')); - + return view('Admin.pages.manage_cms.manage_terms.manage_terms', compact('terms_condition')); } // public function edit($id) // { @@ -22,19 +23,18 @@ class TermsController extends Controller // return view('Admin.pages.manage_cms.manage_terms.manage_terms_edit', compact('terms')); // } public function edit($id) -{ - - $terms = Termsandconditions::find($id); + { + + $terms = Termsandconditions::find($id); // dd($terms); return view('Admin.pages.manage_cms.manage_terms.manage_terms_edit', compact('terms')); - -} + } public function update(Request $request) { - + $validated = $request->validate([ - + 'article_des' => 'required', // Add validation for article_des ]); $update = Termsandconditions::find($request->custom_id); @@ -42,4 +42,23 @@ class TermsController extends Controller $update->save(); return response()->json(['success' => true, 'status' => 200]); } + + + public function editTerms_rest($id) + { + $edit_terms_rest = Termsandconditions::find($id); + // return $edit_terms_rest; + return view('Admin.pages.manage_cms.manage_terms.manage_terns_edit_rest', compact('edit_terms_rest')); + } + + public function update_rest(Request $request) + { + $validated = $request->validate([ + 'termsrest_des' => 'required', + ]); + $update_rest = Termsandconditions::find($request->termRest_id); + $update_rest->message = $request->input('termsrest_des'); + $update_rest->save(); + return response()->json(['success' => true, 'status' => 200]); + } } diff --git a/app/Http/Middleware/CheckStatus.php b/app/Http/Middleware/CheckStatus.php index eb2dee0..7d0c1fa 100644 --- a/app/Http/Middleware/CheckStatus.php +++ b/app/Http/Middleware/CheckStatus.php @@ -4,6 +4,7 @@ namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use Symfony\Component\HttpFoundation\Response; class CheckStatus @@ -17,7 +18,8 @@ class CheckStatus { $admin = auth()->guard('admin')->user(); - if ($admin && $admin->is_active == 1) { + Log::info($admin); + if ($admin && $admin->is_active == 1 && ($admin->principal_type_xid == 1 || $admin->principal_type_xid == 2)) { return $next($request); } else { return redirect('/')->with('error_msg', 'You must be logged in..'); diff --git a/app/Mail/ReplyMail.php b/app/Mail/ReplyMail.php new file mode 100644 index 0000000..8a37a0c --- /dev/null +++ b/app/Mail/ReplyMail.php @@ -0,0 +1,65 @@ +query = $query; + + } + + + + public function build() + { + return $this->view('Admin.pages.mail.reply'); + } + + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'Reply Mail', + ); + } + + /** + * Get the message content definition. + */ + // public function content(): Content + // { + // return new Content( + // view: 'view.name', + // ); + // } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Models/CheckReferralCode.php b/app/Models/CheckReferralCode.php new file mode 100644 index 0000000..4175f78 --- /dev/null +++ b/app/Models/CheckReferralCode.php @@ -0,0 +1,18 @@ +hasMany(ManageModuleLink::class,'principal_xid', 'id'); + return $this->hasMany(ManageModuleLink::class, 'principal_xid', 'id'); } public function feedbacks() @@ -62,7 +64,7 @@ class IamPrincipal extends Authenticatable implements JWTSubject return $customerCount; } - + // protected $fillable = @@ -129,35 +131,35 @@ class IamPrincipal extends Authenticatable implements JWTSubject 'password' => 'hashed', ]; - public function getPermissionGranted($id,$module) + public function getPermissionGranted($id, $module) { // $id is used as authuser id // $moudle is the slug of sidebar module - $isSubAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',2)->first(); - // 'is_admin',1 is for checking the login user is subadmin or not + $isSubAdmin = IamPrincipal::where('id', $id)->where('principal_type_xid', 2)->first(); + // 'is_admin',1 is for checking the login user is subadmin or not - $isMainAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',1)->first(); - if($isMainAdmin){ - return true; - }elseif($isSubAdmin){ - //search for module - $isModule = ManageModule::where('slug',$module)->first(); - if($isModule){ - $isSubAdminModuleLink = ManageModuleLink::where('principal_xid',$id) - ->where('manage_modules_xid',$isModule->id)->first(); - // dd($id,$module,$isSubAdmin->id,$isModule,$isSubAdminModuleLink); - if($isSubAdminModuleLink){ - return true; - }else{ - return false; - } - }else{ - return false; - } - }else{ - return false; - } + $isMainAdmin = IamPrincipal::where('id', $id)->where('principal_type_xid', 1)->first(); + if ($isMainAdmin) { + return true; + } elseif ($isSubAdmin) { + //search for module + $isModule = ManageModule::where('slug', $module)->first(); + if ($isModule) { + $isSubAdminModuleLink = ManageModuleLink::where('principal_xid', $id) + ->where('manage_modules_xid', $isModule->id)->first(); + // dd($id,$module,$isSubAdmin->id,$isModule,$isSubAdminModuleLink); + if ($isSubAdminModuleLink) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } } // public function orders() @@ -183,8 +185,11 @@ class IamPrincipal extends Authenticatable implements JWTSubject // } public function restaurant() -{ - return $this->hasMany(ManageRestaurant::class, 'id', 'restaurant_xid'); -} - + { + return $this->hasMany(ManageRestaurant::class, 'id', 'restaurant_xid'); + } + public function contactMessages() + { + return $this->hasMany(ManageContactus::class, 'principal_xid', 'id'); + } } diff --git a/app/Models/ManageContactus.php b/app/Models/ManageContactus.php index 85c7d24..60a61cd 100644 --- a/app/Models/ManageContactus.php +++ b/app/Models/ManageContactus.php @@ -27,4 +27,8 @@ class ManageContactus extends Model 'created_by', 'modified_by', ]; + public function customer() + { + return $this->belongsTo(IamPrincipal::class, 'principal_xid', 'id'); + } } diff --git a/app/Models/ManageFeedback.php b/app/Models/ManageFeedback.php index 867825b..76b849e 100644 --- a/app/Models/ManageFeedback.php +++ b/app/Models/ManageFeedback.php @@ -1,19 +1,19 @@ belongsTo(FeedbackReaction::class, 'feedback_reaction_xid', 'feedback_reaction_xid'); + return $this->belongsTo(feedbackReaction::class, 'feedback_reaction_xid', 'feedback_reaction_xid'); + } + + + public function restaurant() + { + return $this->belongsTo(ManageRestaurant::class, 'restaurant_id', 'id'); } + } diff --git a/app/Models/ManageRestaurant.php b/app/Models/ManageRestaurant.php index 8fd0202..66bc0f6 100644 --- a/app/Models/ManageRestaurant.php +++ b/app/Models/ManageRestaurant.php @@ -22,7 +22,7 @@ class ManageRestaurant extends Model protected $fillable = [ 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longitude', - 'is_active', 'created_by', 'modified_by' + 'is_active', 'created_by', 'modified_by', 'phone_number','time_hours','max_numb_day','max_numb_week','max_numb_month' ]; protected static function boot() @@ -54,6 +54,6 @@ class ManageRestaurant extends Model return $this->belongsTo(ManageState::class, 'state_xid', 'id'); } - - + + } diff --git a/app/Models/ManageRule.php b/app/Models/ManageRule.php new file mode 100644 index 0000000..088bd05 --- /dev/null +++ b/app/Models/ManageRule.php @@ -0,0 +1,18 @@ +exists()); + $user = IamPrincipal::create([ 'one_signal_player_id' => $request->one_signal_player_id, 'first_name' => $request->first_name, 'last_name' => $request->last_name, 'email_address' => $request->email_address, 'password' => Hash::make($request->password), - 'principal_type_xid' => 3, //3 for customer - 'principal_source_xid' => 2, //2 for mobile + 'principal_type_xid' => 3, // 3 for customer + 'principal_source_xid' => 2, // 2 for mobile 'date_of_birth' => $request->date_of_birth, - // 'address_line1' => $request->address_line1, 'phone_number' => $request->phone_number, - 'state_xid' =>$request->state_xid, + 'state_xid' => $request->state_xid, + 'referral_code' => $referral_code, ]); + DB::commit(); $token = auth()->login($user); @@ -77,11 +83,16 @@ class AuthServices return jsonResponseWithSuccessMessage(__('auth.Customer_user_created'), $response, 200); } catch (QueryException $e) { DB::rollBack(); - Log::error('Restaurant Registration Failed ' . $e->getMessage()); + Log::error('Customer Registration Failed ' . $e->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403); } } + + + + + public function login($request) { try { @@ -155,7 +166,7 @@ class AuthServices ], function ($message) use ($user) { $message->to($user->email_address); - $message->subject('Forgot Password Mail Page'); + $message->subject('One-Time Passcode Enclosed'); } ); @@ -233,7 +244,6 @@ class AuthServices $User->save(); DB::commit(); return jsonResponseWithSuccessMessageApi(__('auth.password_updated_successfully')); - } catch (QueryException $e) { DB::rollBack(); Log::error('Customer change password Failed ' . $e->getMessage()); @@ -300,4 +310,24 @@ class AuthServices return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403); } } + + public function searchState($request) + { + try { + $searchQuery = $request->input('search_data'); + + $query = ManageState::select('id', 'name')->where('is_active', 1); + + if ($searchQuery) { + $query->where(function ($q) use ($searchQuery) { + $q->where('name', '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); + } + } } diff --git a/app/Services/APIs/CustomerAPIs/CMSApiServices.php b/app/Services/APIs/CustomerAPIs/CMSApiServices.php index 1d3634b..fc2058e 100644 --- a/app/Services/APIs/CustomerAPIs/CMSApiServices.php +++ b/app/Services/APIs/CustomerAPIs/CMSApiServices.php @@ -39,19 +39,11 @@ class CMSApiServices $data['customer'] = Aboutus::select('id', 'thumbnail_image', 'description') ->where('category_xid', '1') ->get() - ->map(function ($item) { - $item['description'] = strip_tags($item['description']); - return $item; - }) ->toArray(); $data['restaurant'] = Aboutus::select('id', 'thumbnail_image', 'description') ->where('category_xid', '2') ->get() - ->map(function ($item) { - $item['description'] = strip_tags($item['description']); - return $item; - }) ->toArray(); foreach ($data['customer'] as $k => $val) { $data['customer'][$k]['thumbnail_image'] = ListingImageUrl('about_images', $val['thumbnail_image']); @@ -106,16 +98,14 @@ class CMSApiServices }) ->toArray(); - //thumbnail_image for 'customer' data foreach ($data['customer'] as $k => $val) { $data['customer'][$k]['thumbnail_image'] = ListingImageUrl('news_article_thumb', $val['thumbnail_image']); - $data['customer'][$k]['image'] = ListingImageUrl('news_article', $val['image']); + $data['customer'][$k]['image'] = ListingImageUrl('news_article_image', $val['image']); } - //thumbnail_image for 'restaurant' data foreach ($data['restaurant'] as $k => $val) { $data['restaurant'][$k]['thumbnail_image'] = ListingImageUrl('news_article_thumb', $val['thumbnail_image']); - $data['restaurant'][$k]['image'] = ListingImageUrl('news_article', $val['image']); + $data['restaurant'][$k]['image'] = ListingImageUrl('news_article_image', $val['image']); } return $data; @@ -133,6 +123,11 @@ class CMSApiServices ->get() ->toArray(); + $data['restaurant'] = Termsandconditions::select('id', 'message') + ->where('category_xid', '2') + ->get() + ->toArray(); + return $data; } catch (Exception $ex) { Log::error('Terms and condition Get service failed : ' . $ex->getMessage()); diff --git a/app/Services/APIs/CustomerAPIs/CustomerApiServices.php b/app/Services/APIs/CustomerAPIs/CustomerApiServices.php index 11a80f5..ec06dfc 100644 --- a/app/Services/APIs/CustomerAPIs/CustomerApiServices.php +++ b/app/Services/APIs/CustomerAPIs/CustomerApiServices.php @@ -23,7 +23,8 @@ class CustomerApiServices 'phone_number', 'date_of_birth', 'state_xid', - 'profile_photo' + 'profile_photo', + 'referral_code' )->find($user->id); diff --git a/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php b/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php new file mode 100644 index 0000000..75c7b55 --- /dev/null +++ b/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php @@ -0,0 +1,47 @@ +first(); + $now = Carbon::now(); + $reaction = $request->input('reaction'); + $comment = $request->input('comment'); + + $feedbackData = [ + 'principal_xid' => $user_data->id, + 'feedback_reaction_xid' => $reaction, + 'comment' => $comment, + 'is_app_feedback' => $request->is_app_feedback, + 'is_restaurant_feedback' => $request->is_restaurant_feedback, + 'restaurant_id' => $request->restaurant_id, + ]; + + $feedback = ManageFeedback::create($feedbackData); + + DB::commit(); + Log::info('Feedback added successfully'); + return jsonResponseWithSuccessMessageApi(__('auth.feedback_store'), [], 200); + } catch (Exception $ex) { + DB::rollBack(); + Log::error('Update Quantity service failed: ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } +} diff --git a/app/Services/APIs/CustomerAPIs/ReferralCodeServices.php b/app/Services/APIs/CustomerAPIs/ReferralCodeServices.php new file mode 100644 index 0000000..64188da --- /dev/null +++ b/app/Services/APIs/CustomerAPIs/ReferralCodeServices.php @@ -0,0 +1,50 @@ +referral_code) + ->where('id', '!=', $customerIamId) + ->exists(); + if (!$isExist) { + return jsonResponseWithErrorMessage(__('auth.invalid_referral_code'), 404); + } + + // Check already used 3 times + $referralCodeCount = CheckReferralCode::where('referral_code', $request->referral_code)->count(); + if ($referralCodeCount >= 3) { + return jsonResponseWithErrorMessage(__('auth.limitation_over'), 404); + } + + // Check if the referral code is already used by the same customer + $usedByUser = CheckReferralCode::where('referral_code', $request->referral_code) + ->where('iam_principal_xid', $customerIamId) + ->exists(); + if ($usedByUser) { + return jsonResponseWithErrorMessage(__('auth.already_used_code'), 404); + } + + $storeId = new CheckReferralCode(); + $storeId->iam_principal_xid = $customerIamId; + $storeId->referral_code = $request->referral_code; + $storeId->save(); + + return jsonResponseWithSuccessMessageApi(__('success.redeemed_successfully'), 200); + } catch (Exception $ex) { + Log::error('Check referral code 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 621d7be..f9af473 100644 --- a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php @@ -5,8 +5,11 @@ namespace App\Services\APIs\CustomerAPIs; use Illuminate\Support\Facades\DB; use App\Models\CustomerFavouriteRestaurant; +use App\Models\IamPrincipal; +use App\Models\IamPrincipalRestaurantRole; use App\Models\ManageRestaurant; use App\Models\RedeemRestaurant; +use App\Helpers\onesignalhelper; use Exception; use Illuminate\Support\Facades\Log; @@ -107,20 +110,37 @@ class RestaurantApiServices { try { $rest = ManageRestaurant::with('operatingHours')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude')->where('short_id', $id)->where('is_active', '1')->first(); + if ($rest) { $rest->image = ListingImageUrl('restaurant_images', $rest->image); + $isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId) ->where('restaurant_xid', $rest->id) ->exists(); $rest->is_favourite = $isFavourite; + + $redeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId) + ->where('manage_restaurants_xid', $rest->id) + ->where('is_redeem', "1") + ->first(); + + if ($redeem) { + $rest->is_Redeemed = true; + $rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours(4)->toDateTimeString(); + } else { + $rest->is_Redeemed = false; + $rest->redeem_date = null; + } } + if (!$rest) { return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404); } + return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $rest, 200); - } catch (\Exception $ex) { - Log::error('DetailRestaurant service failed: ' . $ex->getMessage()); - return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } catch (Exception $e) { + Log::error("Error fetching restaurant data: " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } @@ -171,7 +191,10 @@ class RestaurantApiServices $restaurantsQuery->where(function ($query) use ($searchData) { $query->where('name', 'like', "%$searchData%") ->orWhere('description', 'like', "%$searchData%") - ->orWhere('address', 'like', "%$searchData%"); + ->orWhere('address', 'like', "%$searchData%") + ->orWhereHas('state', function ($stateQuery) use ($searchData) { + $stateQuery->where('name', 'like', "%$searchData%"); + }); }); } @@ -202,12 +225,27 @@ class RestaurantApiServices return jsonResponseWithErrorMessageApi(__('auth.restaurant_not_found'), 404); } - // Check if the restaurant has already redeemed - $restaurantExist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->first(); + // Check if the restaurant has already been redeemed + $restaurantExist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId) + ->where('is_redeem', 1) + ->first(); + if ($restaurantExist) { return jsonResponseWithErrorMessageApi(__('auth.restaurant_already_redeemed'), 400); } + // Check if there's an existing entry for the restaurant and update it + $restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId)->first(); + if ($restexist) { + $restexist->is_redeem = 1; + $restexist->redeem_date = now(); + $restexist->is_redeemption_undone = 0; + $restexist->redeemption_undone_date = null; + $restexist->save(); + return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $restexist, 200); + } + + // Create a new redeem entry if it doesn't exist $redeemRestaurant = new RedeemRestaurant(); $redeemRestaurant->iam_principal_xid = $customerIamId; $redeemRestaurant->manage_restaurants_xid = $restaurant->id; @@ -217,12 +255,96 @@ class RestaurantApiServices $redeemRestaurant->redeemption_undone_date = null; $redeemRestaurant->save(); - return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $redeemRestaurant, 200); + + $imagePath = ListingImageUrl('restaurant_images', $restaurant->image); + + $customerTitle = "Your Redemption was successful for " . $restaurant->name; + $customerMessage = $restaurant->name . " Voucher Redeemed Successfully"; + $customerContentType = 'Voucher_Redemption'; + $customerImageUrl = $imagePath; + + $customerData = IamPrincipal::where('id', $customerIamId)->where('notification_status', 1)->where('principal_type_xid', 3)->first(); + $restaurants = IamPrincipalRestaurantRole::select('id', 'principal_xid')->where('restaurant_xid', $restaurant->id)->get(); + + foreach ($restaurants as $restaurant) { + $restUser = IamPrincipal::where('id', $restaurant->principal_xid)->where('notification_status', 1)->where('principal_type_xid', 4)->first(); + + if ($restUser) { + $restImagePath = ListingImageUrl('restaurant_images', $restaurant->image); + $restTitle = "New redemption for " . $restaurant->name; + $restMessage = $restaurant->name . " new voucher Redeemed Successfully"; + $restContent_type = 'Voucher_Redemption'; + $restImageUrl = $restImagePath; + + // Sending notification to restaurant + $pushNotificationToRestaurant = onesignalhelper::restSendNotificationApi( + $restUser->one_signal_player_id, + $restTitle, + $restMessage, + $restContent_type, + $restImageUrl, + $id = null + ); + onesignalhelper::StoreNotificationDetails($restUser->id, $restContent_type, $restTitle, $restImageUrl); + } + } + + if ($customerData) { + // Sending notification to customer + $pushNotificationToCustomer = onesignalhelper::sendNotificationApi( + $customerData->one_signal_player_id, + $customerTitle, + $customerMessage, + $customerContentType, + $customerImageUrl, + $id = null + ); + + onesignalhelper::StoreNotificationDetails($customerData->id, $customerContentType, $customerTitle, $customerImageUrl); + } + return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $redeemRestaurant, 200); } catch (Exception $ex) { Log::error('Restaurant Redeem service failed: ' . $ex->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + public function searchRestaurant($customerIamId, $request) + { + try { + $restaurantsQuery = ManageRestaurant::with(['operatingHours', 'state']) + ->where('is_active', '1'); + + $searchData = $request->input('search_data'); + + if (!empty($searchData)) { + $restaurantsQuery->where(function ($query) use ($searchData) { + $query->where('name', 'like', "%$searchData%") + ->orWhere('description', 'like', "%$searchData%") + ->orWhere('address', 'like', "%$searchData%") + ->orWhereHas('state', function ($stateQuery) use ($searchData) { + $stateQuery->where('name', 'like', "%$searchData%"); + }); + }); + } + + $restaurants = $restaurantsQuery->get(); + + foreach ($restaurants as &$res) { + $res['image'] = ListingImageUrl('restaurant_images', $res['image']); + $res['is_favourite'] = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId) + ->where('restaurant_xid', $res->id) + ->exists(); + } + + return jsonResponseWithSuccessMessageApi(__('auth.restaurant_search'), $restaurants, 200); + } catch (Exception $ex) { + Log::error('Search from restaurant service failed: ' . $ex->getMessage()); + return response()->json([ + 'message' => __('auth.something_went_wrong') + ], 500); + } + } } diff --git a/app/Services/APIs/CustomerAPIs/RulesApiServices.php b/app/Services/APIs/CustomerAPIs/RulesApiServices.php new file mode 100644 index 0000000..a6c35e5 --- /dev/null +++ b/app/Services/APIs/CustomerAPIs/RulesApiServices.php @@ -0,0 +1,25 @@ +get() + ->toArray(); + + return $data; + } catch (Exception $ex) { + Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } +} diff --git a/app/Services/APIs/RestaurantService/RedeemApiService.php b/app/Services/APIs/RestaurantService/RedeemApiService.php index 6146e93..fd29ff4 100644 --- a/app/Services/APIs/RestaurantService/RedeemApiService.php +++ b/app/Services/APIs/RestaurantService/RedeemApiService.php @@ -6,102 +6,110 @@ use App\Helpers\onesignalhelper; use App\Models\admin\ManageVoucherModel; use App\Models\IamPrincipal; use App\Models\IamPrincipalRestaurantRole; +use App\Models\ManageRestaurant; use App\Models\MyPassportVoucher; +use App\Models\RedeemRestaurant; use Exception; use Illuminate\Support\Facades\Log; class RedeemApiService { - public function getRedemedData($restIamId) { try { $rest = IamPrincipal::findOrFail($restIamId); $data['user_detail'] = IamPrincipal::select('id', 'first_name', 'last_name', 'email_address', 'phone_number', 'date_of_birth')->find($rest->id); - $restaurantRoles = IamPrincipalRestaurantRole::select('id', 'principal_xid', 'restaurant_xid', 'role')->where('principal_xid', $rest->id)->get(); + $restaurantRoles = IamPrincipalRestaurantRole::select('id', 'principal_xid', 'restaurant_xid', 'role') + ->where('principal_xid', $rest->id) + ->first(); - $restaurantDetail = []; - foreach ($restaurantRoles as $role) { - $restaurantImage = ManageVoucherModel::select('id', 'coupon_name', 'description', 'thumbnail_image', 'image', 'location_name')->find($role->restaurant_xid); - if ($restaurantImage) { - $restaurantImage->thumbnail_image = ListingImageUrl('voucher_thumbnail_images', $restaurantImage->thumbnail_image); - $restaurantImage->image = ListingImageUrl('voucher_images', $restaurantImage->image); + + $restDetail = RedeemRestaurant::with([ + 'customer:id,first_name,last_name,profile_photo', + 'restaurant:id,short_id,image,name' + ]) + ->select('id', 'iam_principal_xid', 'manage_restaurants_xid', 'redeem_date', 'is_active', 'count') + ->where('manage_restaurants_xid', $restaurantRoles->restaurant_xid) + ->where('is_redeem', 1) + ->get(); + + foreach ($restDetail as $detail) { + if ($detail->customer) { + $detail->customer->profile_photo = $detail->customer->profile_photo + ? ListingImageUrl('profile_image', $detail->customer->profile_photo) + : asset('public/assets/img/blankProfile.png'); } - $restaurantDetail[] = $restaurantImage; - $redeemedVouchers = []; - $redemptionUndoneVouchers = []; - - $vouchers = MyPassportVoucher::select('id', 'order_xid', 'iam_principal_xid', 'manage_passports_xid', 'manage_vouchers_xid', 'is_redeem', 'count', 'redeem_date', 'is_redeemption_undone') - ->where('manage_vouchers_xid', $role->restaurant_xid) - ->where('is_redeem', 1) - ->get(); - - $redeemptionUndone = MyPassportVoucher::select('id', 'order_xid', 'iam_principal_xid', 'manage_passports_xid', 'manage_vouchers_xid', 'is_redeem', 'count', 'redeem_date', 'is_redeemption_undone', 'redeemption_undone_date') - ->where('manage_vouchers_xid', $role->restaurant_xid) - ->where([['is_redeem', 0], ['is_redeemption_undone', 1]]) - ->get(); - - foreach ($vouchers as $voucher) { - $userDetail = IamPrincipal::select('id', 'first_name', 'email_address', 'profile_photo', 'address_line1') - ->where('id', $voucher->iam_principal_xid) - ->first(); - - if ($userDetail) { - if ($userDetail->profile_photo) { - $userDetail->profile_photo = ListingImageUrl('profile_image', $userDetail->profile_photo); - } else { - $userDetail->profile_photo = asset('public/assets/img/blankProfile.png'); - } - - $voucher->user_detail = $userDetail; - $redeemedVouchers[] = $voucher; + if ($detail->restaurant) { + // Check if the image is already a URL + if (!filter_var($detail->restaurant->image, FILTER_VALIDATE_URL)) { + $detail->restaurant->image = ListingImageUrl('restaurant_images', $detail->restaurant->image); } else { - - Log::error('User detail not found for IAM principal ID: ' . $voucher->iam_principal_xid); + // Fallback if the image is already a URL + $detail->restaurant->image = $detail->restaurant->image + ? $detail->restaurant->image + : asset('public/assets/img/blankProfile.png'); } } - - - foreach ($redeemptionUndone as $undone) { - $userDetail = IamPrincipal::select('id', 'first_name', 'email_address', 'profile_photo', 'address_line1') - ->where('id', $undone->iam_principal_xid) - ->first(); - - if ($userDetail) { - if ($userDetail->profile_photo) { - $userDetail->profile_photo = ListingImageUrl('profile_image', $userDetail->profile_photo); - } else { - $userDetail->profile_photo = asset('public/assets/img/blankProfile.png'); - } - - $undone->user_detail = $userDetail; - $redemptionUndoneVouchers[] = $undone; - } else { - - Log::error('User detail not found for IAM principal ID: ' . $undone->iam_principal_xid); - } - } - - - $restaurantDetail['redeemed_vouchers'] = $redeemedVouchers; - $restaurantDetail['redemption_undone_vouchers'] = $redemptionUndoneVouchers; } + $restDetailArray = $restDetail->toArray(); + + + + $restundoresumptionDetail = RedeemRestaurant::with([ + 'customer:id,first_name,last_name,profile_photo', + 'restaurant:id,short_id,image,name' + ]) + ->select('id', 'iam_principal_xid', 'manage_restaurants_xid', 'redeem_date', 'is_active', 'count', 'redeemption_undone_date') + ->where('manage_restaurants_xid', $restaurantRoles->restaurant_xid) + ->where('is_redeemption_undone', 1) + ->get(); + + foreach ($restundoresumptionDetail as $detail) { + if ($detail->customer) { + $detail->customer->profile_photo = $detail->customer->profile_photo + ? ListingImageUrl('profile_image', $detail->customer->profile_photo) + : asset('public/assets/img/blankProfile.png'); + } + + if ($detail->restaurant) { + // Check if the image is already a URL + if (!filter_var($detail->restaurant->image, FILTER_VALIDATE_URL)) { + $detail->restaurant->image = ListingImageUrl('restaurant_images', $detail->restaurant->image); + } else { + // Fallback if the image is already a URL + $detail->restaurant->image = $detail->restaurant->image + ? $detail->restaurant->image + : asset('public/assets/img/blankProfile.png'); + } + } + } + $restundoRedumption = $restundoresumptionDetail->toArray(); + + + $restaurantDetail = [ + 'redeemed_vouchers' => $restDetailArray, + 'redemption_undone_vouchers' => $restundoRedumption, + ]; + return jsonResponseWithSuccessMessageApi(__('auth.User_details_fetch'), $restaurantDetail, 200); } catch (Exception $ex) { - Log::error('Restaurant Get data service failed : ' . $ex->getMessage()); + Log::error('Redeem Restaurant Get data service failed: ' . $ex->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + public function undoRedemption($restIamId, $request) { try { - $voucherDetail = MyPassportVoucher::with('passportData', 'voucherData')->where('id', $request->voucher_id)->first(); + $voucherDetail = RedeemRestaurant::where('id', $request->voucher_id)->first(); + $rest = ManageRestaurant::where('id', $voucherDetail->manage_restaurants_xid)->first(); if ($voucherDetail) { $voucherDetail->update([ 'is_redeem' => 0, @@ -110,9 +118,9 @@ class RedeemApiService 'redeemption_undone_date' => now(), ]); - $imagePath = ListingImageUrl('voucher_images', $voucherDetail->voucherData->image); - $customerTitle = "Your voucher was successfully undo redemption for " . $voucherDetail->passportData->passport_name; - $customerMessage = $voucherDetail->voucherData->coupon_name . " Voucher Undo Redemption Successfully"; + $imagePath = ListingImageUrl('restaurant_images', $rest->image); + $customerTitle = "Your voucher was successfully undo redemption for " . $rest->name; + $customerMessage = $rest->name . " Voucher Undo Redemption Successfully"; $customerContentType = 'Voucher_UndoRedemption'; $customerImageUrl = $imagePath; $customerData = IamPrincipal::where('id', $voucherDetail->iam_principal_xid)->where('notification_status', 1)->where('principal_type_xid', 3)->first(); @@ -130,9 +138,9 @@ class RedeemApiService } $restUser = IamPrincipal::where('id', $restIamId)->where('notification_status', 1)->where('principal_type_xid', 4)->first(); if ($restUser) { - $restImagePath = ListingImageUrl('voucher_images', $voucherDetail->voucherData->image); - $restTitle = "voucher Undo redemption successful for " . $voucherDetail->passportData->passport_name; - $restMessage = $voucherDetail->voucherData->coupon_name . " Voucher Undo Redemption Successfully"; + $restImagePath = ListingImageUrl('voucher_images', $rest->image); + $restTitle = "voucher Undo redemption successful for " . $rest->name; + $restMessage = $rest->image . " Voucher Undo Redemption Successfully"; $restContentType = 'Voucher_UndoRedemption'; $restImageUrl = $restImagePath; @@ -152,13 +160,16 @@ class RedeemApiService return jsonResponseWithErrorMessageApi(__('auth.voucher_not_found'), 404); } } catch (Exception $ex) { - Log::error('Restaurant update profile service failed: ' . $ex->getMessage()); + Log::error('Undo redumption service failed: ' . $ex->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } - public function searchRedemption($restIamId, $request) + + + + public function searchRedemption($restIamId, $request) { try { $searchQuery = $request->input('search_data'); @@ -166,83 +177,105 @@ class RedeemApiService $rest = IamPrincipal::findOrFail($restIamId); $data['user_detail'] = IamPrincipal::select('id', 'first_name', 'last_name', 'email_address', 'phone_number', 'date_of_birth')->find($rest->id); - $restaurantRoles = IamPrincipalRestaurantRole::select('id', 'principal_xid', 'restaurant_xid', 'role')->where('principal_xid', $rest->id)->get(); + $restaurantRoles = IamPrincipalRestaurantRole::select('id', 'principal_xid', 'restaurant_xid', 'role') + ->where('principal_xid', $rest->id) + ->first(); - $restaurantDetail = []; - foreach ($restaurantRoles as $role) { - $restaurantImage = ManageVoucherModel::select('id', 'coupon_name', 'description', 'thumbnail_image', 'image', 'location_name')->find($role->restaurant_xid); - if ($restaurantImage) { - $restaurantImage->thumbnail_image = ListingImageUrl('voucher_thumbnail_images', $restaurantImage->thumbnail_image); - $restaurantImage->image = ListingImageUrl('voucher_images', $restaurantImage->image); - } - $restaurantDetail[] = $restaurantImage; + $query = RedeemRestaurant::with([ + 'customer:id,first_name,last_name,profile_photo', + 'restaurant:id,image,name' + ]) + ->select('id', 'iam_principal_xid', 'manage_restaurants_xid', 'redeem_date', 'is_active', 'count') + ->where('manage_restaurants_xid', $restaurantRoles->restaurant_xid) + ->where('is_redeem', 1); - $redeemedVouchers = []; - $redemptionUndoneVouchers = []; - - $vouchers = MyPassportVoucher::select('id', 'order_xid', 'iam_principal_xid', 'manage_passports_xid', 'manage_vouchers_xid', 'is_redeem', 'count', 'redeem_date', 'is_redeemption_undone') - ->where('manage_vouchers_xid', $role->restaurant_xid) - ->where('is_redeem', 1) - ->get(); - - foreach ($vouchers as $voucher) { - $userDetail = IamPrincipal::select('id', 'first_name', 'email_address', 'profile_photo', 'address_line1') - ->where('id', $voucher->iam_principal_xid) - ->first(); - - if ($userDetail && (stripos($userDetail->first_name, $searchQuery) !== false || stripos($voucher->id, $searchQuery) !== false || stripos($voucher->redeem_date, $searchQuery) !== false)) { - if ($userDetail->profile_photo) { - $userDetail->profile_photo = ListingImageUrl('profile_image', $userDetail->profile_photo); - } else { - $userDetail->profile_photo = asset('public/assets/img/blankProfile.png'); - } - - $voucher->user_detail = $userDetail; - $redeemedVouchers[] = $voucher; - } else { - - Log::error('User detail not found for IAM principal ID: ' . $voucher->iam_principal_xid); - } - } - - $redeemptionUndone = MyPassportVoucher::select('id', 'order_xid', 'iam_principal_xid', 'manage_passports_xid', 'manage_vouchers_xid', 'is_redeem', 'count', 'redeem_date', 'is_redeemption_undone', 'redeemption_undone_date') - ->where('manage_vouchers_xid', $role->restaurant_xid) - ->where([['is_redeem', 0], ['is_redeemption_undone', 1]]) - ->get(); - - foreach ($redeemptionUndone as $undone) { - $userDetail = IamPrincipal::select('id', 'first_name', 'email_address', 'profile_photo', 'address_line1') - ->where('id', $undone->iam_principal_xid) - ->first(); - - if ($userDetail && (stripos($userDetail->first_name, $searchQuery) !== false || stripos($undone->id, $searchQuery) !== false || stripos($undone->redeemption_undone_date, $searchQuery) !== false)) { - if ($userDetail->profile_photo) { - $userDetail->profile_photo = ListingImageUrl('profile_image', $userDetail->profile_photo); - } else { - $userDetail->profile_photo = asset('public/assets/img/blankProfile.png'); - } - - $undone->user_detail = $userDetail; - $redemptionUndoneVouchers[] = $undone; - } else { - - Log::error('User detail not found for IAM principal ID: ' . $undone->iam_principal_xid); - } - } - - if (empty($searchQuery)) { - $restaurantDetail['redeemed_vouchers'] = $redeemedVouchers; - $restaurantDetail['redemption_undone_vouchers'] = $redemptionUndoneVouchers; - } - - $restaurantDetail['redeemed_vouchers'] = $redeemedVouchers; - $restaurantDetail['redemption_undone_vouchers'] = $redemptionUndoneVouchers; + if ($searchQuery) { + $query->where(function ($q) use ($searchQuery) { + $q->where('id', $searchQuery) + ->orWhereHas('customer', function ($q) use ($searchQuery) { + $q->where('first_name', 'like', '%' . $searchQuery . '%') + ->orWhere('last_name', 'like', '%' . $searchQuery . '%'); + }) + ->orWhereDate('redeem_date', $searchQuery); + }); } + + + $restDetail = $query->get(); + + foreach ($restDetail as $detail) { + if ($detail->customer) { + $detail->customer->profile_photo = $detail->customer->profile_photo + ? ListingImageUrl('profile_image', $detail->customer->profile_photo) + : asset('public/assets/img/blankProfile.png'); + } + + if ($detail->restaurant) { + if (!filter_var($detail->restaurant->image, FILTER_VALIDATE_URL)) { + $detail->restaurant->image = ListingImageUrl('restaurant_images', $detail->restaurant->image); + } else { + $detail->restaurant->image = $detail->restaurant->image + ? $detail->restaurant->image + : asset('public/assets/img/blankProfile.png'); + } + } + } + + $restDetailArray = $restDetail->toArray(); + + $queryUndo = RedeemRestaurant::with([ + 'customer:id,first_name,last_name,profile_photo', + 'restaurant:id,image,name' + ]) + ->select('id', 'iam_principal_xid', 'manage_restaurants_xid', 'redeem_date', 'is_active', 'count', 'redeemption_undone_date') + ->where('manage_restaurants_xid', $restaurantRoles->restaurant_xid) + ->where('is_redeemption_undone', 1); + + if ($searchQuery) { + $queryUndo->where(function ($q) use ($searchQuery) { + $q->where('id', $searchQuery) + ->orWhereHas('customer', function ($q) use ($searchQuery) { + $q->where('first_name', 'like', '%' . $searchQuery . '%') + ->orWhere('last_name', 'like', '%' . $searchQuery . '%'); + }) + ->orWhereDate('redeemption_undone_date', $searchQuery); + }); + } + + + + $restundoresumptionDetail = $queryUndo->get(); + + foreach ($restundoresumptionDetail as $detail) { + if ($detail->customer) { + $detail->customer->profile_photo = $detail->customer->profile_photo + ? ListingImageUrl('profile_image', $detail->customer->profile_photo) + : asset('public/assets/img/blankProfile.png'); + } + + if ($detail->restaurant) { + if (!filter_var($detail->restaurant->image, FILTER_VALIDATE_URL)) { + $detail->restaurant->image = ListingImageUrl('restaurant_images', $detail->restaurant->image); + } else { + $detail->restaurant->image = $detail->restaurant->image + ? $detail->restaurant->image + : asset('public/assets/img/blankProfile.png'); + } + } + } + $restundoRedumption = $restundoresumptionDetail->toArray(); + + $restaurantDetail = [ + 'redeemed_vouchers' => $restDetailArray, + 'redemption_undone_vouchers' => $restundoRedumption, + ]; + return jsonResponseWithSuccessMessageApi(__('auth.User_details_fetch'), $restaurantDetail, 200); } catch (Exception $ex) { - Log::error('Restaurant Get data service failed : ' . $ex->getMessage()); + Log::error('Search voucher service failed: ' . $ex->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + } diff --git a/app/Services/APIs/RestaurantService/RestAuthApiService.php b/app/Services/APIs/RestaurantService/RestAuthApiService.php index 5025d27..f1a2400 100644 --- a/app/Services/APIs/RestaurantService/RestAuthApiService.php +++ b/app/Services/APIs/RestaurantService/RestAuthApiService.php @@ -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(); @@ -69,7 +69,7 @@ class RestAuthApiService 'phone_number' => $request->phone_number, 'date_of_birth' => $request->date_of_birth, 'is_active' => '0', - 'state_xid' => $request->state_xid + // 'state_xid' => $request->state_xid ]); $restaurantUserRole = IamPrincipalRestaurantRole::create([ @@ -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); + } + } } diff --git a/app/Services/APIs/RestaurantService/RestCMSService.php b/app/Services/APIs/RestaurantService/RestCMSService.php index 1eb2f4c..9003759 100644 --- a/app/Services/APIs/RestaurantService/RestCMSService.php +++ b/app/Services/APIs/RestaurantService/RestCMSService.php @@ -104,8 +104,8 @@ class RestCMSService public function RestNewsArticles() { try { - $data['customer'] = NewsArticle::select('id', 'news_articles_category_xid','name', 'description', 'thumbnail_image', 'image',) - ->where([['is_active', '0'], ['news_articles_category_xid', '1']]) + $data['customer'] = NewsArticle::select('id', 'name', 'description', 'thumbnail_image', 'image') + ->where([['is_active', '1'], ['news_articles_category_xid', '1']]) ->get() ->map(function ($item) { $item['description'] = strip_tags($item['description']); @@ -114,7 +114,7 @@ class RestCMSService ->toArray(); $data['restaurant'] = NewsArticle::select('id', 'news_articles_category_xid','name', 'description', 'thumbnail_image', 'image') - ->where([['is_active', '0'], ['news_articles_category_xid', '2']]) + ->where([['is_active', '1'], ['news_articles_category_xid', '2']]) ->get() ->map(function ($item) { $item['description'] = strip_tags($item['description']); diff --git a/app/Services/APIs/RestaurantService/RestaurantApi_Service.php b/app/Services/APIs/RestaurantService/RestaurantApi_Service.php index 03d73f0..fdb4624 100644 --- a/app/Services/APIs/RestaurantService/RestaurantApi_Service.php +++ b/app/Services/APIs/RestaurantService/RestaurantApi_Service.php @@ -1,7 +1,8 @@ where('id', $restaurantRole->restaurant_xid) ->where('is_active', 1) ->first(); @@ -72,7 +73,7 @@ class RestaurantApi_Service - + public function updateRestaurantDetail($restIamId, $request) { try { @@ -98,11 +99,12 @@ class RestaurantApi_Service 'name' => $request['name'], 'address' => $request['address'], 'bio' => $request['bio'], + 'phone_number' => $request['phone_number'], 'try_on_1' => $request['try_on_1'], 'try_on_2' => $request['try_on_2'], 'try_on_3' => $request['try_on_3'], 'try_on_4' => $request['try_on_4'], - + ]); $restaurant->description = strip_tags($restaurant->description); @@ -131,7 +133,6 @@ class RestaurantApi_Service $tnormalImage = saveSingleImageWithoutCrop($image, 'profile_image', null); $data->update(['profile_photo' => $tnormalImage]); DB::commit(); - } if ($request->has('first_name')) { $data->first_name = $request->first_name; diff --git a/database/migrations/2024_01_22_100217_create_news_articles_table.php b/database/migrations/2024_01_22_100217_create_news_articles_table.php index 3135cb8..8b8c864 100644 --- a/database/migrations/2024_01_22_100217_create_news_articles_table.php +++ b/database/migrations/2024_01_22_100217_create_news_articles_table.php @@ -19,7 +19,7 @@ return new class extends Migration $table->longText('description'); $table->string('thumbnail_image'); $table->string('image'); - $table->enum('is_active',['0','1'])->comment('0 = Active, 1 = Inactive'); + $table->enum('is_active',['0','1'])->default(1)->comment('0 = Active, 1 = Inactive'); $table->softDeletes(); $table->timestamps(); diff --git a/database/migrations/2024_02_02_061343_create_feedback_reaction.php b/database/migrations/2024_02_02_061343_create_feedback_reaction.php new file mode 100644 index 0000000..142e7f0 --- /dev/null +++ b/database/migrations/2024_02_02_061343_create_feedback_reaction.php @@ -0,0 +1,31 @@ +id(); + $table->integer('feedback_reaction_xid')->nullable(); + $table->string('feedback_reaction_title')->nullable(); + $table->integer('created_by')->nullable(); + $table->integer('modified_by')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('feedback_reaction'); + } +}; diff --git a/database/migrations/2024_02_02_063443_create_manage_feedback_table.php b/database/migrations/2024_02_02_063443_create_manage_feedback_table.php new file mode 100644 index 0000000..9787c16 --- /dev/null +++ b/database/migrations/2024_02_02_063443_create_manage_feedback_table.php @@ -0,0 +1,48 @@ +id(); + + // Foreign key references for principal + $table->unsignedBigInteger('principal_xid'); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + + // Feedback reaction and comment columns + + $table->unsignedBigInteger('feedback_reaction_xid'); + $table->foreign('feedback_reaction_xid')->references('id')->on('feedback_reaction')->onDelete('cascade'); + + $table->longtext('comment')->nullable(); + $table->boolean('is_app_feedback')->default(0); + $table->boolean('is_restaurant_feedback')->default(0); + $table->integer('restaurant_id')->nullable(); + + + // Soft deletes, timestamps, and additional columns + $table->softDeletes(); + $table->timestamps(); + $table->boolean('is_active')->default(1)->comment('1=Active, 0=Deactive'); + $table->integer('created_by')->nullable(); + $table->integer('modified_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('manage_feedback'); + } +}; diff --git a/database/migrations/2024_05_28_095429_create_manage_restaurants_table.php b/database/migrations/2024_05_28_095429_create_manage_restaurants_table.php index 57a3573..58948c4 100644 --- a/database/migrations/2024_05_28_095429_create_manage_restaurants_table.php +++ b/database/migrations/2024_05_28_095429_create_manage_restaurants_table.php @@ -15,19 +15,25 @@ return new class extends Migration Schema::create('manage_restaurants', function (Blueprint $table) { $table->id(); $table->string('short_id')->unique(); - $table->string('name',255)->nullable(); + $table->string('name', 255)->nullable(); $table->longText('description')->nullable(); + $table->string('phone_number', 15)->nullable(); + $table->bigInteger('state_xid')->nullable(); $table->string('restaurant_id')->nullable(); - $table->string('address',255)->nullable(); + $table->string('address', 255)->nullable(); $table->string('image')->nullable(); $table->string('bio')->nullable(); $table->text('try_on_1')->nullable(); $table->text('try_on_2')->nullable(); $table->text('try_on_3')->nullable(); $table->text('try_on_4')->nullable(); - $table->string('exclusion',255)->nullable(); + $table->string('exclusion', 255)->nullable(); $table->string('latitude'); $table->string('longtitude'); + $table->integer('time_hours')->default(1)->comment('Time in hours between redeeming two cocktails'); + $table->integer('max_numb_day')->default(1)->comment('Maximum number of cocktails per day'); + $table->integer('max_numb_week')->default(1)->comment('Maximum number of cocktails per week'); + $table->integer('max_numb_month')->default(1)->comment('Maximum number of cocktails per month'); $table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired'); $table->integer('created_by')->nullable(); $table->integer('modified_by')->nullable(); diff --git a/database/migrations/2024_05_31_095128_create_notification_details.php b/database/migrations/2024_05_31_095128_create_notification_details.php index ba5adff..35b6eba 100644 --- a/database/migrations/2024_05_31_095128_create_notification_details.php +++ b/database/migrations/2024_05_31_095128_create_notification_details.php @@ -15,7 +15,7 @@ return new class extends Migration $table->id(); $table->unsignedBigInteger('principal_xid'); $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); - $table->integer('type'); + $table->string('type'); $table->longText('description'); $table->string('image')->nullable(); $table->timestamp('date_added')->useCurrent(); diff --git a/database/migrations/2024_06_14_074342_update_existing_referral_codes_in_iam_principal_table.php b/database/migrations/2024_06_14_074342_update_existing_referral_codes_in_iam_principal_table.php new file mode 100644 index 0000000..8bc36a7 --- /dev/null +++ b/database/migrations/2024_06_14_074342_update_existing_referral_codes_in_iam_principal_table.php @@ -0,0 +1,37 @@ +where('principal_type_xid', 3)->whereNull('referral_code')->orWhere('referral_code', '')->get(); + + foreach ($users as $user) { + do { + $referral_code = \Str::random(10); + } while (DB::table('iam_principal')->where('referral_code', $referral_code)->exists()); + + DB::table('iam_principal') + ->where('id', $user->id) + ->update(['referral_code' => $referral_code]); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('iam_principal', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2024_06_14_074534_add_unique_constraint_to_referral_code_in_iam_principal_table.php b/database/migrations/2024_06_14_074534_add_unique_constraint_to_referral_code_in_iam_principal_table.php new file mode 100644 index 0000000..d73b44e --- /dev/null +++ b/database/migrations/2024_06_14_074534_add_unique_constraint_to_referral_code_in_iam_principal_table.php @@ -0,0 +1,28 @@ +string('referral_code')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('iam_principal', function (Blueprint $table) { + $table->string('referral_code')->nullable(false)->change(); + }); + } +}; diff --git a/database/migrations/2024_06_14_091912_create_check_referral_code_table.php b/database/migrations/2024_06_14_091912_create_check_referral_code_table.php new file mode 100644 index 0000000..7e3920c --- /dev/null +++ b/database/migrations/2024_06_14_091912_create_check_referral_code_table.php @@ -0,0 +1,31 @@ +id(); + $table->unsignedBigInteger('iam_principal_xid'); + $table->string('referral_code'); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('check_referral_code'); + } +}; diff --git a/database/migrations/2024_06_19_063218_create_manage_rules_table.php b/database/migrations/2024_06_19_063218_create_manage_rules_table.php new file mode 100644 index 0000000..014cd4e --- /dev/null +++ b/database/migrations/2024_06_19_063218_create_manage_rules_table.php @@ -0,0 +1,29 @@ +id(); + $table->longtext('title')->nullable(); + $table->longtext('message')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('manage_rules'); + } +}; diff --git a/public/assets/css/light/custom.css b/public/assets/css/light/custom.css index 0a26da2..18c1297 100644 --- a/public/assets/css/light/custom.css +++ b/public/assets/css/light/custom.css @@ -1,5 +1,9 @@ /*# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlcyI6WyJjdXN0b20uc2NzcyJdLCJzb3VyY2VzQ29udGVudCI6WyIiXSwiZmlsZSI6ImN1c3RvbS5jc3MifQ== */ +.arrow-icon-spacing { + margin-left: 10px; +} + .notification-scroll h2 { font-size: 20px; font-weight: bold; @@ -1373,7 +1377,7 @@ label { /* to change error class color */ label#email-error ,label#password-error { color: red; -} + font-weight: 600;} .error-message { @@ -1560,3 +1564,33 @@ a.download-btn.reply-button:hover { width: fit-content !important; padding: 10px 20px; } + +/* +.random_cl li { + list-style: circle !important; +} */ +.random_cl li a { + position: relative; + display: flex; + justify-content: space-between; + padding: 10.2px 16px 10.2px 24px; + margin-left: 34px; + font-size: 15px; + color: #000; +} +.random_cl li a:before { + content: ""; + background-color: #000; + position: absolute; + height: 7px; + width: 7px; + top: 15px; + left: 5px; + border-radius: 50%; +} +.random_cl li a:hover { + color: #fff; + background: #05244d; +} + + diff --git a/public/assets/css/light/main.css b/public/assets/css/light/main.css index 0a32411..efbf6c0 100644 --- a/public/assets/css/light/main.css +++ b/public/assets/css/light/main.css @@ -536,7 +536,7 @@ input[type=search]::-ms-reveal { /* Form Group Label */ .form-group label, label { font-size: 15px; - color: #0e1726; + color: #1a1919; letter-spacing: 1px; display: inline-block; margin-bottom: 0.5rem; diff --git a/public/assets/js/admin/auth/login.js b/public/assets/js/admin/auth/login.js index 31cbbc2..6602b7c 100644 --- a/public/assets/js/admin/auth/login.js +++ b/public/assets/js/admin/auth/login.js @@ -1,13 +1,13 @@ // Login js $(document).on("click", "#admin_login_btn", function (e) { - $('#admin_login_form').validate({ + $("#admin_login_form").validate({ rules: { email: { required: true, }, password: { required: true, - } + }, }, messages: { email: { @@ -15,7 +15,7 @@ $(document).on("click", "#admin_login_btn", function (e) { }, password: { required: "Please enter the password.", - } + }, }, submitHandler: function (form) { e.preventDefault(); @@ -23,64 +23,68 @@ $(document).on("click", "#admin_login_btn", function (e) { var formData = new FormData(form); $.ajaxSetup({ headers: { - "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr( + "content" + ), }, }); $.ajax({ - url: base_url + '/check_login', - type: 'POST', + url: base_url + "/check_login", + type: "POST", data: formData, - beforeSend:function(){ - $('#admin_login_btn').text('Please wait...'); - $('#admin_login_btn').attr('disabled', true); + beforeSend: function () { + $("#admin_login_btn").text("Please wait..."); + $("#admin_login_btn").attr("disabled", true); }, processData: false, contentType: false, success: function (response) { if (response.status == 200) { - $('#admin_login_btn').prop('disabled', false); - $('#admin_login_btn').text('Login'); + $("#admin_login_btn").prop("disabled", false); + $("#admin_login_btn").text("Login"); window.location.href = base_url + "/dashboard"; - } + } if (response.status == 401) { toastr.error(response.message); form.reset(); - $('#admin_login_btn').prop('disabled', false); - $('#admin_login_btn').text('Sign In'); + $("#admin_login_btn").prop("disabled", false); + $("#admin_login_btn").text("Sign In"); } }, }); - } + }, }); }); // forgot password js $(document).on("click", "#forgot_password_btn", function (e) { let base_url = url_path; - $('#forgot_pass_form').validate({ + $("#forgot_pass_form").validate({ ignore: [], debug: false, rules: { email: { - required: true - } + required: true, + }, }, messages: { email: { - required: "Please Enter email" - } + required: "Please Enter email", + }, }, submitHandler: function (form) { var formData = new FormData(form); e.preventDefault(), - $.ajaxSetup({ - headers: { - "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), - }, - }); + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr( + "content" + ), + }, + }); $.ajax({ - url: base_url + '/send_otp', - type: 'POST', + url: base_url + "/send_otp", + type: "POST", data: formData, processData: false, contentType: false, @@ -88,51 +92,53 @@ $(document).on("click", "#forgot_password_btn", function (e) { console.log(response); if (response.status == 200) { form.reset(); - toastr.success('Otp send it your mail id please check'); + toastr.success("Otp send it your mail id please check"); setTimeout(function () { -// toastr.info('Please check your email to reset your password. The link is valid for 5 minutes.'); + // toastr.info('Please check your email to reset your password. The link is valid for 5 minutes.'); window.location.href = base_url + "/otp"; }, 1000); - }else if (response.status == 404) { - toastr.error('This email id is not exits'); - } - else { + } else if (response.status == 404) { + toastr.error("This email id is not exits"); + } else { toastr.error("Something went wrong"); } }, }); - } + }, }); }); // otp varification -$(document).on('click', '#otp_verify_button', function(e) { +$(document).on("click", "#otp_verify_button", function (e) { e.preventDefault(); // Get base URL let base_url = url_path; // Get admin ID - var id = $('#admin_otp_id').val(); + var id = $("#admin_otp_id").val(); // Get OTP by concatenating values of all OTP input fields - var otp = $('.otp').map(function() { - return this.value; - }).get().join(''); + var otp = $(".otp") + .map(function () { + return this.value; + }) + .get() + .join(""); // Send AJAX request for OTP verification $.ajax({ - url: base_url + '/otp_verify', - type: 'POST', + url: base_url + "/otp_verify", + type: "POST", data: { id: id, otp: otp, - '_token': $('meta[name="csrf-token"]').attr('content') + _token: $('meta[name="csrf-token"]').attr("content"), }, success: function (response) { if (response.status == 200) { // Display success message - toastr.success('Otp Verify Successfully'); + toastr.success("Otp Verify Successfully"); // Redirect to the dashboard after a delay setTimeout(function () { window.location.href = base_url + "/password_reset"; @@ -148,34 +154,35 @@ $(document).on('click', '#otp_verify_button', function(e) { }); }); - -$(document).on('input', '.otp', function() { - this.value = this.value.replace(/[^0-9]/g, ''); +$(document).on("input", ".otp", function () { + this.value = this.value.replace(/[^0-9]/g, ""); if (this.value.length >= this.maxLength) { - $(this).next('.otp').focus(); + $(this).next(".otp").focus(); } }); // Reset Password $(document).on("click", "#password_reset", function (e) { - $('#password_reset_form').validate({ + $("#password_reset_form").validate({ rules: { password: { required: true, + minlength: 8, }, confirm_password: { required: true, - equalTo: "#password" + equalTo: "#password", }, }, messages: { password: { required: "Please enter a password.", + minlength: "The password field must be at least 8 characters.", }, confirm_password: { required: "Please Confirm Your Password", - equalTo: "Your Password Do Not Match" + equalTo: "Your Password Do Not Match", }, }, submitHandler: function (form) { @@ -185,43 +192,47 @@ $(document).on("click", "#password_reset", function (e) { $.ajaxSetup({ headers: { - "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr( + "content" + ), }, }); $.ajax({ - url: base_url + '/password_update', - type: 'POST', + url: base_url + "/password_update", + type: "POST", data: formData, processData: false, contentType: false, success: function (response) { - if (response.status == 200) { - $('#password_reset').prop('disabled', false); - $('#password_reset').text('Login'); - window.location.href = base_url + "/"; - } - if (response.status == 401) { + if (response.status_code == 200) { + $("#password_reset").prop("disabled", false); + $("#password_reset").text("Login"); + toastr.success(response.message); + setTimeout(function () { + window.location.href = base_url + "/"; + }, 1000); + } + if (response.status_code == 401) { toastr.error(response.message); form.reset(); - $('#password_reset').prop('disabled', false); - $('#password_reset').text('Sign In'); + $("#password_reset").prop("disabled", false); + $("#password_reset").text("Sign In"); } }, }); - } + }, }); }); -$('#passwordToggle').click(function () { - var passwordInput = $('#password'); - var eyeIcon = $('#passwordToggle'); +$("#passwordToggle").click(function () { + var passwordInput = $("#password"); + var eyeIcon = $("#passwordToggle"); - if (passwordInput.attr('type') === 'password') { - passwordInput.attr('type', 'text'); - eyeIcon.removeClass('fa-eye-slash').addClass('fa-eye'); + if (passwordInput.attr("type") === "password") { + passwordInput.attr("type", "text"); + eyeIcon.removeClass("fa-eye-slash").addClass("fa-eye"); } else { - passwordInput.attr('type', 'password'); - eyeIcon.removeClass('fa-eye').addClass('fa-eye-slash'); + passwordInput.attr("type", "password"); + eyeIcon.removeClass("fa-eye").addClass("fa-eye-slash"); } }); - diff --git a/public/assets/js/admin/manage_cms/manage_news/add_news.js b/public/assets/js/admin/manage_cms/manage_news/add_news.js index 804e1bd..3cbf8db 100644 --- a/public/assets/js/admin/manage_cms/manage_news/add_news.js +++ b/public/assets/js/admin/manage_cms/manage_news/add_news.js @@ -1,95 +1,97 @@ -// $('#add_newsletter').on("click", function (e) { - -// $.validator.addMethod("quillNotEmpty", function(value, element) { -// var quill = new Quill('#news-quill-add'); -// return quill.getText().trim().length > 0; -// }, "Please enter description "); +$('#add_newsletter').on("click", function (e) { +// alert('jh'); + // $.validator.addMethod("quillNotEmpty", function(value, element) { + // var quill = new Quill('#news-quill-add'); + // return quill.getText().trim().length > 0; + // }, "Please enter description "); -// $('#add_blog_form').validate({ -// ignore: [], -// debug: false, -// rules: { -// article_name: { -// required: true -// }, -// article_dis: { -// required: true, -// quillNotEmpty: true -// }, -// article_image: { -// required: true -// }, -// article_thmb: { -// required: true -// }, -// category: { -// required: true -// }, -// }, -// messages: { -// article_name: { -// required: "Please Enter Article name" -// }, -// article_dis: { -// required: "Please Enter Description" -// }, -// article_image: { -// required: "Please Select Image" -// }, -// category: { -// required: "Please Select Article Category" -// }, -// }, -// errorClass: 'error-message', -// submitHandler: function (form) { -// let base_url = url_path; -// var formData = new FormData(form); -// $('#add_newsletter').text('Please wait...').attr('disabled', true); + $('#add_blog_form').validate({ + // ignore: [], + // debug: false, + rules: { + article_name: { + required: true + }, + article_dis: { + required: true, + quillNotEmpty: true + }, + article_image: { + required: true + }, + article_thmb: { + required: true + }, + category: { + required: true + }, + }, + messages: { + article_name: { + required: "Please Enter Article name" + }, + article_dis: { + required: "Please Enter Description" + }, + article_image: { + required: "Please Select Image" + }, + category: { + required: "Please Select Article Category" + }, + }, + errorClass: 'error-message', + submitHandler: function (form) { -// $.ajaxSetup({ -// headers: { -// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), -// }, -// }); + var quillContent = quill.root.innerHTML; + $('#article_des').val(quillContent);base_url = url_path; + var formData = new FormData(form); + $('#add_newsletter').text('Please wait...').attr('disabled', true); + + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), + }, + }); -// $.ajax({ -// url: base_url + '/manage_insert_news', -// type: 'POST', -// data: formData, -// processData: false, -// contentType: false, -// success: function (response) { -// if (response.status == 200) { -// toastr.success('News and Article Added Successfully'); -// setTimeout(function () { -// window.location.href = base_url + "/manage_news"; -// }, 1000); -// } else { -// toastr.error("Something went wrong"); -// } -// $('#add_newsletter').attr('disabled', false).text('Submit'); -// }, -// }); -// } -// }); -// }); + $.ajax({ + url: base_url + '/manage_insert_news', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (response) { + if (response.status == 200) { + toastr.success('News and Article Added Successfully'); + setTimeout(function () { + window.location.href = base_url + "/manage-new-articles"; + }, 1000); + } else { + toastr.error("Something went wrong"); + } + $('#add_newsletter').attr('disabled', false).text('Submit'); + }, + }); + } + }); +}); -// selectThumbnailImage.onchange = evt => { -// preview = document.getElementById('previewthumbnailimage'); -// preview.style.display = 'block'; -// const [file] = selectThumbnailImage.files -// if (file) { -// preview.src = URL.createObjectURL(file) -// } -// } +selectThumbnailImage.onchange = evt => { + preview = document.getElementById('previewthumbnailimage'); + preview.style.display = 'block'; + const [file] = selectThumbnailImage.files + if (file) { + preview.src = URL.createObjectURL(file) + } +} -// selectImage.onchange = evt => { -// preview = document.getElementById('preview'); -// preview.style.display = 'block'; -// const [file] = selectImage.files -// if (file) { -// preview.src = URL.createObjectURL(file) -// } -// } \ No newline at end of file +selectImage.onchange = evt => { + preview = document.getElementById('preview'); + preview.style.display = 'block'; + const [file] = selectImage.files + if (file) { + preview.src = URL.createObjectURL(file) + } +} \ No newline at end of file diff --git a/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js b/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js index c738b02..3f1c5f1 100644 --- a/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js +++ b/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js @@ -76,57 +76,83 @@ $(document).ready(function() { }); +$(document).ready(function() { + var quill = new Quill('#termsRest-quill-edit', { + theme: 'snow' + }); + + var storedMessage = document.getElementById('stored-terms-rest-message').value; + quill.clipboard.dangerouslyPasteHTML(storedMessage); + + $('#update_termsrest').on("click", function(e) { + e.preventDefault(); + $('#terms_rest_form').validate({ + ignore: [], + debug: false, + rules: { + termsrest_des: { + required: true, + minlength:1000, + } + }, + messages: { + termsrest_des: { + required: "Please Enter Terms and Condition", + minlength:"Please Enter Terms and Condition" + } + }, + errorClass: 'error-message', + + submitHandler: function(form) { + // Get the HTML content from Quill editor + var termsrest_des = quill.root.innerHTML; + + if (termsrest_des.trim() === '


') { + toastr.error("Please Enter Terms and Condition"); + return false; + } + + let base_url = url_path; + var termRest_id = document.querySelector('input[name="termRest_id"]').value; + + // Create a form data object + var formData = new FormData(form); + formData.append('termsrest_des', termsrest_des); + + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), + }, + }); + + $.ajax({ + url: base_url + '/update_terms_rest', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function(response) { + if (response.status == 200) { + toastr.success('Terms and Condition Data Updated Successfully'); + setTimeout(function() { + window.location.href = base_url + "/terms"; + }, 1000); + } else { + toastr.error("Something went wrong"); + } + }, + error: function(response) { + toastr.error("An error occurred while updating the terms"); + } + }); + } + }); + + // Trigger form validation + $('#terms_rest_form').submit(); + }); +}); - -// privacy policy for rest -// $('#update_terms_rest').on("click", function (e) { -// $('#update_terms_rest_form').validate({ -// ignore: [], -// debug: false, -// rules: { -// article_des_rest: { -// required: true, -// quillNotEmpty: true -// } -// }, -// messages: { -// article_des_rest: { -// required: "Please Enter Terms and Condition" -// } -// }, -// errorClass: 'error-message', -// submitHandler: function (form) { -// let base_url = url_path; -// var formData = new FormData(form); -// $.ajaxSetup({ -// headers: { -// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), -// }, -// }); -// $.ajax({ -// url: base_url + '/update_terms_rest', -// type: 'POST', -// data: formData, -// processData: false, -// contentType: false, -// success: function (response) { -// if (response.status == 200) { -// toastr.success('Terms and Condtion Data Updated Successfully'); -// setTimeout(function () { -// window.location.href = base_url + "/terms"; -// }, 1000); -// } -// else if (response.status == 204) { -// toastr.error(response.error); -// } -// else { -// toastr.error("Something went wrong"); -// } -// }, -// }); -// } -// }); -// }); \ No newline at end of file diff --git a/public/assets/js/admin/manage_customer/edit.js b/public/assets/js/admin/manage_customer/edit.js index 5c0a3ec..525f950 100644 --- a/public/assets/js/admin/manage_customer/edit.js +++ b/public/assets/js/admin/manage_customer/edit.js @@ -17,7 +17,7 @@ $(document).on("click", "#customer_user_btn", function (e) { required: true, fullNameCharactersOnly: true }, - email_id: { + email_address: { required: true, email: true, }, @@ -34,7 +34,7 @@ $(document).on("click", "#customer_user_btn", function (e) { required: "Enter Passport Name", alphaCharactersOnly: "Please enter only alphabetical characters" }, - email_id: { + email_address: { required: "Enter email address", email: "Please enter a valid email address" }, @@ -66,14 +66,15 @@ $(document).on("click", "#customer_user_btn", function (e) { processData: false, contentType: false, success: function(result) { + console.log(result); if (result.status_code == 200) { - toastr.success('Customer Updated Sucessfully'); + toastr.success('Customer Updated Successfully'); setTimeout(function() { window.location.href = base_url + "/manage-customer"; }, 2000); } else { - toastr.error('Something Went Wrong'); + toastr.error(result.message); setTimeout(function() { window.location.href = base_url + "/manage-customer"; }, 2000); @@ -81,11 +82,29 @@ $(document).on("click", "#customer_user_btn", function (e) { $('#customer_user_btn').attr('disabled', false); $('#customer_user_btn').text('Submit'); }, - + error: function(xhr) { + console.log(xhr); + if (xhr.status === 422) { + var errors = xhr.responseJSON.errors; + for (var key in errors) { + if (errors.hasOwnProperty(key)) { + toastr.error(errors[key][0]); // Show the first error message for each field + } + } + } else { + toastr.error('Something Went Wrong'); + } + $('#customer_user_btn').attr('disabled', false); + $('#customer_user_btn').text('Submit'); + } }); + $('#customer_user_btn').attr('disabled', false); $('#customer_user_btn').text('Submit'); } }); -}); \ No newline at end of file +}); + + + diff --git a/public/assets/js/admin/manage_customer/main.js b/public/assets/js/admin/manage_customer/main.js index 2d3d142..e982f70 100644 --- a/public/assets/js/admin/manage_customer/main.js +++ b/public/assets/js/admin/manage_customer/main.js @@ -15,7 +15,7 @@ $('#zero-config').DataTable({ "pageLength": 10, "ordering": true, // Enable global ordering "columnDefs": [ - { "orderable": false, "targets": [0, 1, 2] } // Disable ordering for the first column (checkboxes) and the eighth column + // { "orderable": false, "targets": [0, 1, 2] } // Disable ordering for the first column (checkboxes) and the eighth column ] }); @@ -70,7 +70,7 @@ $(document).on("click", ".customer_unarchive", function (e) { url: base_url + "/manage_customer_unarchive/" + archive_id, success: function (response) { if (response.status == 200) { - toastr.success('Record has been '); + toastr.success('The user has been unarchived.'); setTimeout(function () { window.location.href = base_url + "/manage-customer"; }, 1000); @@ -140,3 +140,11 @@ $(document).on("click", ".more", function (e) { + + + + + + + + diff --git a/public/assets/js/admin/manage_location/add_location.js b/public/assets/js/admin/manage_location/add_location.js index eb2a082..4c4b088 100644 --- a/public/assets/js/admin/manage_location/add_location.js +++ b/public/assets/js/admin/manage_location/add_location.js @@ -1,3 +1,45 @@ +// $(document).on("click", "#submit_location", function (e) { +// $('#store_location').validate({ +// rules: { +// location_name: { +// required: true, +// } +// }, +// messages: { +// location_name: { +// required: "Please enter the state.", +// } +// }, +// errorClass: 'error-message', +// submitHandler: function (form) { +// e.preventDefault(); +// let base_url = url_path; +// var formData = new FormData(form); +// $.ajaxSetup({ +// headers: { +// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), +// }, +// }); +// $.ajax({ +// url: base_url + '/insert_location', +// type: 'POST', +// data: formData, +// processData: false, +// contentType: false, +// success: function (response) { +// if (response.status == 200) { +// toastr.success('Location added successfully'); +// setTimeout(function () { +// window.location.href = base_url + "/manage_location"; +// }, 1000); +// } else { +// toastr.error("Something went wrong"); +// } +// }, +// }); +// } +// }); +// }); $(document).on("click", "#submit_location", function (e) { $('#store_location').validate({ rules: { @@ -7,7 +49,7 @@ $(document).on("click", "#submit_location", function (e) { }, messages: { location_name: { - required: "Please enter the city.", + required: "Please enter the state.", } }, errorClass: 'error-message', @@ -32,11 +74,21 @@ $(document).on("click", "#submit_location", function (e) { setTimeout(function () { window.location.href = base_url + "/manage_location"; }, 1000); + } else if (response.status == 422 && response.error === 'Location name already exists') { + toastr.error('Location name already exists'); } else { toastr.error("Something went wrong"); } }, + error: function (xhr, status, error) { + // Handle the case where the server returns an error + if (xhr.status == 422 && xhr.responseJSON.error === 'Location name already exists') { + toastr.error('Location name already exists'); + } else { + toastr.error("An error occurred"); + } + } }); } }); -}); \ No newline at end of file +}); diff --git a/public/assets/js/admin/manage_location/edit_location.js b/public/assets/js/admin/manage_location/edit_location.js index ec20386..e088cc9 100644 --- a/public/assets/js/admin/manage_location/edit_location.js +++ b/public/assets/js/admin/manage_location/edit_location.js @@ -6,6 +6,7 @@ $(document).on("click", ".edit_location_value", function (e) { }); + $('#edit_location').validate({ rules: { location_name: { @@ -14,14 +15,14 @@ $('#edit_location').validate({ }, messages: { location_name: { - required: "Please enter the city.", + required: "Please enter the state.", } }, errorClass: 'error-message', submitHandler: function (form) { var formData = new FormData(form); $('#update_passport_btn').text('Please wait...'); - $('#update_passport_btn').attr('disabled', true); + $('#update_passport_btn').attr('disabled', true); let base_url = url_path; $.ajax({ url: base_url + '/update_location', @@ -30,13 +31,16 @@ $('#edit_location').validate({ processData: false, contentType: false, success: function(result) { - - if (result.status_code == 200) { + if (result.status === 200) { toastr.success('Location Updated successfully'); setTimeout(function() { window.location.href = base_url + "/manage_location"; }, 2000); - } else { + } + else if (result.status === 422 && result.error === 'Location name already exists') { + toastr.error('Location name already exists'); + } + else { toastr.error('Something Went Wrong'); setTimeout(function() { window.location.href = base_url + "/manage_location"; @@ -45,8 +49,11 @@ $('#edit_location').validate({ $('#update_passport_btn').attr('disabled', false); $('#update_passport_btn').text('Submit'); }, + error: function(xhr, status, error) { + toastr.error('Something Went Wrong'); + $('#update_passport_btn').attr('disabled', false); + $('#update_passport_btn').text('Submit'); + } }); - $('#update_passport_btn').attr('disabled', false); - $('#update_passport_btn').text('Submit'); } -}); \ No newline at end of file +}); diff --git a/public/assets/js/admin/manage_restaurant/add_restaurant.js b/public/assets/js/admin/manage_restaurant/add_restaurant.js index 57036c7..c834ea4 100644 --- a/public/assets/js/admin/manage_restaurant/add_restaurant.js +++ b/public/assets/js/admin/manage_restaurant/add_restaurant.js @@ -6,7 +6,7 @@ $(document).on("click", "#update_restaurant_btn", function (e) { name: { required: true }, - description: { + state_xid: { required: true, }, rest_id: { @@ -18,7 +18,7 @@ $(document).on("click", "#update_restaurant_btn", function (e) { image: { required: true, }, - exclusion: { + phone_number: { required: true, }, latitude: { @@ -50,13 +50,33 @@ $(document).on("click", "#update_restaurant_btn", function (e) { try_on_4: { required: true, }, + timeHours: { + required: true, + number: true, + min: 1 + }, + maxNumbDay: { + required: true, + number: true, + min: 1 + }, + maxNumbWeek: { + required: true, + number: true, + min: 1 + }, + maxNumbMonth: { + required: true, + number: true, + min: 1 + } }, messages: { name: { required: "Enter restaurant Name", }, - description: { - required: "Enter Description", + state_xid: { + required: "Please Select state", }, rest_id: { required: "Enter restaurant Id", @@ -67,8 +87,8 @@ $(document).on("click", "#update_restaurant_btn", function (e) { image: { required: "Please insert image", }, - exclusion: { - required: "Please enter exclusion", + phone_number: { + required: "Please enter phone number", }, latitude: { required: "Please enter latitude", @@ -93,6 +113,26 @@ $(document).on("click", "#update_restaurant_btn", function (e) { try_on_4: { required: "Please enter this field", }, + timeHours: { + required: "Please enter the time in hours between redeeming two cocktails", + number: "Time must be a number", + min: "Time must be greater than 0" + }, + maxNumbDay: { + required: "Please enter the maximum number of cocktails per day", + number: "Value must be a number", + min: "Value must be greater than 0" + }, + maxNumbWeek: { + required: "Please enter the maximum number of cocktails per week", + number: "Value must be a number", + min: "Value must be greater than 0" + }, + maxNumbMonth: { + required: "Please enter the maximum number of cocktails per month", + number: "Value must be a number", + min: "Value must be greater than 0" + } }, errorClass: 'error-message', submitHandler: function (form) { @@ -144,3 +184,4 @@ $(document).on("click", "#update_restaurant_btn", function (e) { }); }); + diff --git a/public/assets/js/admin/manage_restaurant/main.js b/public/assets/js/admin/manage_restaurant/main.js index 9cf4bc5..b5682de 100644 --- a/public/assets/js/admin/manage_restaurant/main.js +++ b/public/assets/js/admin/manage_restaurant/main.js @@ -84,7 +84,7 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // let base_url = url_path; // var status = $(this).prop("checked") == true ? 1 : 0; // var rest_user_id = $(this).data("id"); - + // $.ajax({ // type: "GET", // dataType: "json", @@ -112,7 +112,7 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // let base_url = url_path; // var rest_user_id = $(this).data("id"); // var status = 1; - + // $.ajax({ // type: "GET", // dataType: "json", @@ -126,19 +126,19 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // "timeOut": 500 // } // toastr.success("User approved and status activated successfully. !!"); - + // // Update the switch to active // $('#switch' + rest_user_id).prop('checked', true); // }, // }); // }); - + // // Handle disapprove button click // $(".disapprove-btn").on("click", function () { // let base_url = url_path; // var rest_user_id = $(this).data("id"); // var status = 0; - + // $.ajax({ // type: "GET", // dataType: "json", @@ -149,112 +149,30 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // }, // success: function (data) { // toastr.error("User disapproved and status deactivated successfully. !!"); - + // // Update the switch to inactive // $('#switch' + rest_user_id).prop('checked', false); // }, // }); // }); - - + + // $(".rest_users_table").on("change", ".active_rest_user", function () { // // Revert the switch change // var rest_user_id = $(this).data("id"); // var currentStatus = $(this).prop("checked"); - + // // Revert the switch state // $(this).prop("checked", !currentStatus); - + // toastr.options = { // "timeOut": 6000 // } // toastr.error("You can only change the status using Approve/Disapprove buttons."); // }); - + // }); - $(document).ready(function () { - // Handle approve button click - $(".approve-btn").on("click", function () { - let base_url = url_path; - var rest_user_id = $(this).data("id"); - var switchElement = $('#switch' + rest_user_id); - - // Check current status - if (switchElement.prop('checked')) { - toastr.options = { - "timeOut": 500 - } - toastr.warning("User is already approved. !!"); - return; - } - - $.ajax({ - type: "GET", - dataType: "json", - url: base_url + '/change_rest_status', - data: { - status: 1, - rest_user_id: rest_user_id, - }, - success: function (data) { - toastr.options = { - "timeOut": 500 - } - toastr.success("User approved and status activated successfully. !!"); - - // Update the switch to active - switchElement.prop('checked', true); - }, - }); - }); - - // Handle disapprove button click - $(".disapprove-btn").on("click", function () { - let base_url = url_path; - var rest_user_id = $(this).data("id"); - var switchElement = $('#switch' + rest_user_id); - - // Check current status - if (!switchElement.prop('checked')) { - toastr.options = { - "timeOut": 500 - } - toastr.warning("User is already disapproved. !!"); - return; - } - - $.ajax({ - type: "GET", - dataType: "json", - url: base_url + '/change_rest_status', - data: { - status: 0, - rest_user_id: rest_user_id, - }, - success: function (data) { - toastr.error("User disapproved and status deactivated successfully. !!"); - - // Update the switch to inactive - switchElement.prop('checked', false); - }, - }); - }); - - // Handle switch change - $(".rest_users_table").on("change", ".active_rest_user", function () { - // Revert the switch change - var currentStatus = $(this).prop("checked"); - - // Revert the switch state - $(this).prop("checked", !currentStatus); - - toastr.options = { - "timeOut": 500 - } - toastr.error("You can only change the status using Approve/Disapprove buttons."); - }); - }); - + // $(document).ready(function() { // // console.log('dfkjb'); // $('#rest_user_form').validate({ @@ -271,17 +189,17 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // user_birth:{ // required: true, // }, - + // restaurant_email: { // required: true, // email: true, // }, - + // restaurant_phone: { // required: true, // numericCharactersOnly: true // }, - + // }, // messages: { // first_name: { @@ -294,17 +212,17 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // user_birth:{ // required: "Please enter date of birth", // }, - + // restaurant_email: { // required: "Enter email address", // email: "Please enter a valid email address" // }, - + // restaurant_phone: { // required: "Enter Phone Number", // numericCharactersOnly: "Please enter only numeric characters" // }, - + // }, // errorClass: 'error-message', // submitHandler: function(form) { @@ -313,7 +231,7 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // // console.log(formData); // $('#restaturant_btn').text('Please wait...'); // $('#restaturant_btn').attr('disabled', true); - + // $.ajaxSetup({ // headers: { // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') @@ -349,6 +267,5 @@ $(document).on("click", ".restaurant_unarchive", function (e) { // } // }); // }) - - - \ No newline at end of file + + diff --git a/public/assets/js/admin/manage_rule/edit_rule.js b/public/assets/js/admin/manage_rule/edit_rule.js new file mode 100644 index 0000000..ae9500b --- /dev/null +++ b/public/assets/js/admin/manage_rule/edit_rule.js @@ -0,0 +1,91 @@ +// $(document).ready(function() { +// var quillTitle = new Quill('#rules-quill-edit-title', { +// theme: 'snow' +// }); + +// // var quillMessage = new Quill('#rules-quill-edit-message', { +// // theme: 'snow' +// // }); + +// var storedTitle = document.getElementById('stored-title-message').value; +// quillTitle.clipboard.dangerouslyPasteHTML(storedTitle); + +// // var storedMessage = document.getElementById('stored-message-message').value; +// // quillMessage.clipboard.dangerouslyPasteHTML(storedMessage); + +// $('#update_rules').on("click", function(e) { +// e.preventDefault(); + +// $('#rules_form').validate({ +// ignore: [], +// debug: false, +// rules: { +// article_des_title: { +// required: true, +// minlength: 10, +// }, +// article_des_message: { +// required: true, +// minlength: 10, +// } +// }, +// messages: { +// article_des_title: { +// required: "Please Enter Rules Title", +// minlength: "Please Enter Rules Title" +// }, +// article_des_message: { +// required: "Please Enter Rules Message", +// minlength: "Please Enter Rules Message" +// } +// }, +// errorClass: 'error-message', +// submitHandler: function(form) { +// var article_des_title = quillTitle.root.innerHTML; +// var article_des_message = quillMessage.root.innerHTML; + +// if (article_des_title.trim() === '


' || article_des_message.trim() === '


') { +// toastr.error("Please Enter Rules"); +// return false; +// } + +// let base_url = url_path; +// var rule_id = document.querySelector('input[name="rule_id"]').value; + +// var formData = new FormData(form); +// formData.append('article_des_title', article_des_title); +// formData.append('article_des_message', article_des_message); + +// $.ajaxSetup({ +// headers: { +// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), +// }, +// }); + +// $.ajax({ +// url: base_url + '/update_rules', +// type: 'POST', +// data: formData, +// processData: false, +// contentType: false, +// success: function(response) { +// if (response.status == 200) { +// toastr.success('Rules Data Updated Successfully'); +// setTimeout(function() { +// window.location.href = base_url + "/manage_rules"; +// }, 1000); +// } else { +// toastr.error("Something went wrong"); +// } +// }, +// error: function(xhr, textStatus, errorThrown) { +// console.error(xhr.responseText); +// toastr.error("An error occurred while updating the rules"); +// } +// }); +// } +// }); + +// $('#rules_form').submit(); +// }); +// }); diff --git a/public/assets/js/admin/manage_sub_admin/add.js b/public/assets/js/admin/manage_sub_admin/add.js index 32bffaf..437c17e 100644 --- a/public/assets/js/admin/manage_sub_admin/add.js +++ b/public/assets/js/admin/manage_sub_admin/add.js @@ -11,6 +11,11 @@ $(document).on("click", "#add_sub_admin_form_btn", function (e) { required: true, lettersOnly: true + }, + sub_admin_lname: { + required: true, + lettersOnly: true + }, sub_admin_email: { required: true, @@ -26,18 +31,22 @@ $(document).on("click", "#add_sub_admin_form_btn", function (e) { }, messages: { sub_admin_name: { - required: 'Please enter this filed', + required: 'Please enter this field', + + }, + sub_admin_lname: { + required: 'Please enter this field', }, sub_admin_email: { - required: 'Please enter this filed', + required: 'Please enter this field', email: 'Please enter a valid email address' }, password: { - required: 'Please enter this filed' + required: 'Please enter this field' }, "module_id[]":{ - required: 'Please enter this filed' + required: 'Please enter this field' } }, errorClass: 'error-message', diff --git a/public/assets/js/admin/manage_sub_admin/edit.js b/public/assets/js/admin/manage_sub_admin/edit.js index 7d33c6d..e0e0903 100644 --- a/public/assets/js/admin/manage_sub_admin/edit.js +++ b/public/assets/js/admin/manage_sub_admin/edit.js @@ -1,4 +1,5 @@ $('#update_admin_btn').on("click", function (e) { + // alert('sdhjgf'); $('#update_sub_admin').validate({ ignore: [], debug: false, @@ -6,16 +7,23 @@ $('#update_admin_btn').on("click", function (e) { sub_admin_name: { required: true }, + sub_admin_lname: { + required: true, + + }, sub_admin_email: { required: true } }, messages: { sub_admin_name: { - required: 'Please enter this filed' + required: 'Please enter this field' + }, + ssub_admin_lname: { + required: 'Please enter this field' }, sub_admin_email: { - required: 'Please enter this filed' + required: 'Please enter this field' } }, errorClass: 'error-message', diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 2286bd1..a69a834 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -12,9 +12,9 @@ return [ | these language lines according to your application's requirements. | */ - 'logout'=>'Your account has been logged out successfully.', - 'try_resend_otp'=>'You can resend OTP only after a 2-minutes interval', - 'otp_already_used'=>'OTP has been used already .', + 'logout' => 'Your account has been logged out successfully.', + 'try_resend_otp' => 'You can resend OTP only after a 2-minutes interval', + 'otp_already_used' => 'OTP has been used already .', 'failed' => 'These credentials do not match our records.', 'email' => 'Email not found.', 'password' => 'The provided password is incorrect.', @@ -25,7 +25,7 @@ return [ 'something_went_wrong' => 'Something went wrong.', 'number_blocked' => 'Your number is blocked for next 24 hours.', 'otp_sent_successfully' => 'OTP sent successfully.', - 'otp_resend_sent_successfully'=>'OTP resend Successfully', + 'otp_resend_sent_successfully' => 'OTP resend Successfully', 'failed_otp' => 'OTP Failed.', 'otp_expired' => 'OTP expired.', 'invalid_otp' => 'Invalid OTP.', @@ -107,5 +107,8 @@ return [ 'restaurant_already_favourite' => 'restaurant already in favourite list', 'restaurant_redeem' => 'Restaurant redeem successfully', 'restaurant_already_redeemed' => 'Restaurant is already redeemed', + 'invalid_referral_code' => 'The provided referral code is invalid.', + 'limitation_over' => 'The redemption limit for this referral code has been reached.', + 'already_used_code' => 'This referral code has already been used.', ]; diff --git a/resources/lang/en/success.php b/resources/lang/en/success.php index 03cb371..d09ced8 100644 --- a/resources/lang/en/success.php +++ b/resources/lang/en/success.php @@ -12,18 +12,18 @@ return [ | these language lines according to your application's requirements. | */ - 'payment_intent_created'=>'Payment Intent Created Successfully', + 'payment_intent_created' => 'Payment Intent Created Successfully', 'data_fetched_successfully' => 'Data Fetched Successfully.', 'otp_sent_successfully' => 'OTP sent successfully.', 'data_not_found' => 'Data not found.', 'password_reset' => 'Password Reset Successfully.', - 'reply_sent' =>'Reply Send Successfully.', + 'reply_sent' => 'Reply Send Successfully.', 'delete' => 'Data Deleted Successfully.', 'update_data' => 'Data Updated Successfully.', 'save_data' => 'Data Saved Successfully.', 'data_already_saved' => 'Data has been saved.', 'change_status' => 'Published.', - 'inactive' =>'Unpublished.', + 'inactive' => 'Unpublished.', 'validation' => 'Validation Failed. ', 'update_status_active' => 'Status Activate successfully.', 'update_status_inactive' => 'Status Deactivate successfully.', @@ -31,7 +31,8 @@ return [ 'date_check' => 'Date must be greater than today date', 'redeem_voucher' => 'Voucher redeemed successfully.', 'sent_mail' => 'Mail sent successfully', - 'authentic_success' => 'Authentication successful', + 'authentic_success' => 'Authentication Successful', 'confirmed_password' => 'please confirm your passsword', + 'redeemed_successfully' => 'Referral code redeemed successfully.', ]; diff --git a/resources/views/Admin/dashboard.blade.php b/resources/views/Admin/dashboard.blade.php index 8cf4625..44f56ce 100644 --- a/resources/views/Admin/dashboard.blade.php +++ b/resources/views/Admin/dashboard.blade.php @@ -17,12 +17,14 @@
-
No of Customers
-

{{ $customerCount }}

+ +
No of Customers
+

{{ $customerCount }}

+
- {{--
+ {{--
-
-
--}} +
+ --}}
-
No of Restaurants
-

{{ $restaurantCount }}

+ +
No of Restaurants
+

{{ $restaurantCount }}

+
- + {{--
+
+
+
+
Sales Graph
+ +
+
+
+
+
+
--}} + + + + + --> + --> + + --> @endsection @section('section_script') - - + + - - @endsection diff --git a/resources/views/Admin/layouts/master.blade.php b/resources/views/Admin/layouts/master.blade.php index ce003d2..5f38120 100644 --- a/resources/views/Admin/layouts/master.blade.php +++ b/resources/views/Admin/layouts/master.blade.php @@ -100,59 +100,39 @@ + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-users')) + - - - - + @endif {{--
  • " data-tooltip="3"> + +
    + + Manage Restaurant +
    +
    +
  • -
  • - -
    - - Manage Restaurant -
    -
    -
  • - - {{--
  • + {{--
  • @@ -193,19 +173,36 @@
  • --}} + @endif + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-contact-us')) +
  • + +
    + + Manage Contact Us +
    +
    +
  • + @endif -
  • - -
    - - Manage Contact Us -
    -
    -
  • + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-state')) +
  • + +
    + + Manage States +
    +
    +
  • + @endif @@ -300,58 +297,79 @@ --> + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-cms')) +
  • + +
    + + Manage CMS +
    +
    +
  • + @endif + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-reports-analysis')) +
  • + +
    + + Manage Reports +
    +
    +
  • + @endif -
  • - -
    - - Manage CMS -
    -
    -
  • + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-feedback')) +
  • + +
    + + Manage Feedback +
    +
    +
  • + @endif -
  • - -
    - - Manage Reports -
    -
    -
  • + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-rules')) +
  • + +
    + + Manage Rules +
    +
    +
  • + @endif -
  • - -
    - - Manage Feedback -
    -
    -
  • - -
  • - -
    - - Manage Notification -
    -
    -
  • + @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-notification')) +
  • + +
    + + Manage Notification +
    +
    +
  • + @endif
    - + +
    +
    - +
    @@ -35,6 +109,11 @@
    + + + + + @@ -44,99 +123,119 @@ @section('scripts') - - if (passwordInput.attr('type') === 'password') { - passwordInput.attr('type', 'text'); - eyeIcon.removeClass('fa-eye-slash').addClass('fa-eye'); + + + + - $.ajax({ - url: base_url + '/password_update', - type: 'POST', - data: formData, - processData: false, - contentType: false, - success: function(response) { - if (response.status_code == 200) { - toastr.success(response.message); - window.location.href = base_url + "/"; - } else if (response.status_code == 401) { - toastr.error(response.message); - form.reset(); - } - $('#password_reset').prop('disabled', false).text('Sign In'); - }, - error: function(xhr) { - if (xhr.status === 422) { - var errors = xhr.responseJSON.message; - $.each(errors, function(index, value) { - toastr.error(value); - }); - } else { - toastr.error('An unexpected error occurred. Please try again.'); - } - $('#password_reset').prop('disabled', false).text('Sign In'); - } - }); - } - }); - $(document).on("click", "#password_reset", function(e) { - e.preventDefault(); - $('#password_reset_form').submit(); - }); - }); - diff --git a/resources/views/Admin/pages/mail/reply.blade.php b/resources/views/Admin/pages/mail/reply.blade.php new file mode 100644 index 0000000..9dd68e5 --- /dev/null +++ b/resources/views/Admin/pages/mail/reply.blade.php @@ -0,0 +1,18 @@ + + + + + Contact Query Reply + + +

    Hello {{ $query->name }},

    + + + +

    Your contact query has been answered:

    + +

    {{ $query->reply_message }}

    + +

    Thank you for reaching out!

    + + diff --git a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us.blade.php b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us.blade.php index 1ce88b8..df633b5 100644 --- a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us.blade.php +++ b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us.blade.php @@ -16,7 +16,7 @@
    Customer About Us
    - + Edit Details
    diff --git a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_cust.blade.php b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_cust.blade.php index e827d6c..0d2c6bf 100644 --- a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_cust.blade.php +++ b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_cust.blade.php @@ -26,15 +26,15 @@
    -
    +
    - -
    {!! $edit_privacy_policy['description'] !!}
    - + +
    {!! $edit_aboutUs_cust['description'] !!}
    +
    -
    @@ -69,5 +69,57 @@ - + @endsection \ No newline at end of file diff --git a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_rest.blade.php b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_rest.blade.php index 842290c..5f75936 100644 --- a/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_rest.blade.php +++ b/resources/views/Admin/pages/manage_cms/manage_aboutus/manage_about_us_rest.blade.php @@ -24,7 +24,7 @@
    - +
    Edit Details of Resturant
    @@ -38,15 +38,15 @@
    - +
    - -
    {!! $edit_about_rest['description'] !!}
    - + +
    {!! $edit_about_rest['description'] !!}
    +
    -
    @@ -65,7 +65,7 @@ @endsection @section('section_script') + @endsection diff --git a/resources/views/Admin/pages/manage_cms/manage_faq/manage_faq.blade.php b/resources/views/Admin/pages/manage_cms/manage_faq/manage_faq.blade.php index 10e39f1..c132c0f 100644 --- a/resources/views/Admin/pages/manage_cms/manage_faq/manage_faq.blade.php +++ b/resources/views/Admin/pages/manage_cms/manage_faq/manage_faq.blade.php @@ -35,22 +35,17 @@ $currentPage = 'manage-faq'; } - -
    -
    +
    Manage FAQ
    -
    - -
    -
    +
    @@ -64,7 +59,7 @@ $currentPage = 'manage-faq'; - + @foreach ($faq as $index => $faqs) @@ -86,50 +81,6 @@ $currentPage = 'manage-faq'; {{ \Carbon\Carbon::parse($faqs['created_at'])->format('m/d/Y') }} @endif - - - @endforeach @@ -169,89 +110,86 @@ $currentPage = 'manage-faq'; - -
    Action
    {{ $index + 1 }}
    @@ -141,25 +92,15 @@ $currentPage = 'manage-faq'; - - - - - -
    - - - - - - - - - - - @foreach ($news_article as $news_articles) - - - - - - - - - +
    -
    - -
    -
    Sr noArticle NameAdded Date ImageAction
    -
    - -
    -
    {{$loop->iteration}}{{ $news_articles['name'] }}{{ \Carbon\Carbon::parse($news_articles['created_at'])->format('m/d/Y') }} -
    - -
      -
    • -
      - - +
      +
      + + + + + + + + + + + + + @foreach ($news_article as $news_articles) + + + + + + + + - + + + + + + + @endforeach - @endforeach - - -
      Sr noArticle NameAdded Date ImageCategoryAction
      {{ $loop->iteration }}{{ $news_articles['name'] }} + {{ \Carbon\Carbon::parse($news_articles['created_at'])->format('m/d/Y') }} + {{ $news_articles['category']['name'] }} +
      + + -
      -
      +
    +
    -
    -