From dde6ea73240b02fcba0128eef3224e8b96542e43 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Mon, 27 May 2024 12:30:30 +0530 Subject: [PATCH] Add state in register --- .../APIs/Customer_API/AuthController.php | 31 ++++++++++++++---- .../APIs/Customer_API/CMSApiController.php | 23 +++++++++++++ .../Customer_API/ContactUsApiController.php | 4 +-- app/Models/IamPrincipal.php | 1 + app/Models/ManageState.php | 11 +++++++ .../APIs/CustomerAPIs/AuthServices.php | 17 +++++++++- .../APIs/CustomerAPIs/CMSApiServices.php | 17 ++++++++++ ...2024_05_27_055629_create_manage_states.php | 32 +++++++++++++++++++ routes/customer_api.php | 5 ++- 9 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 app/Models/ManageState.php create mode 100644 database/migrations/2024_05_27_055629_create_manage_states.php diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php index 83aa327..b2e02a0 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php @@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Hash; use Illuminate\Database\QueryException; use App\Models\IamPrincipal; +use App\Models\ManageState; use Carbon\Carbon; use Exception; use Illuminate\Support\Facades\Log; @@ -50,6 +51,22 @@ class AuthController extends Controller } } + /** + * Created By : sayli Raut + * Created at : 06 Feb 2024 + * Use : Restaurant Details. + */ + public function viewstates() + { + try { + $response = $this->AuthServices->viewstates(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + } catch (\Exception $e) { + Log::error('FAW get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + /** * Created By : sayli Raut * Created at : 24 May 2024 @@ -60,6 +77,7 @@ class AuthController extends Controller try { $validator = Validator::make($request->all(), [ 'first_name' => 'required|string|min:2|max:100', + 'last_name' => 'required|string|min:2|max:100', 'email_address' => [ 'required', 'string', @@ -84,7 +102,9 @@ class AuthController extends Controller }, ], 'phone_number' => 'required|min:10', - 'address_line1' => 'required|max:50', + // 'address_line1' => 'required|max:50', + 'state_xid' => 'required', + ]); @@ -128,7 +148,7 @@ class AuthController extends Controller } } - /** + /** * Created By : sayli Raut * Created at : 24 May 2024 * Use : forgot password. @@ -156,7 +176,6 @@ class AuthController extends Controller return jsonResponseWithErrorMessageApi($validationErrors, 403); } return $this->AuthServices->forgotPassword($request); - } catch (Exception $e) { Log::error('Customer Forgot Password OTP function failed: ' . $e->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); @@ -193,7 +212,6 @@ class AuthController extends Controller return jsonResponseWithErrorMessageApi($validationErrors, 403); } return $this->AuthServices->verifyOTPForgotPassword($request); - } catch (Exception $e) { DB::rollBack(); Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage()); @@ -201,7 +219,7 @@ class AuthController extends Controller } } - /** + /** * Created By : sayli Raut * Created at : 24 May 2024 * Use : Change Password. @@ -219,14 +237,13 @@ class AuthController extends Controller return jsonResponseWithErrorMessageApi($validationErrors, 403); } return $this->AuthServices->changePassword($request); - } catch (Exception $e) { Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage()); return response()->json(__('something_went_wrong'), 500); } } - /** + /** * Created By : sayli Raut * Created at : 24 May 2024 * Use : Resend OTP . diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php b/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php index 756b94f..7e2e0c6 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php @@ -105,4 +105,27 @@ class CMSApiController extends Controller } } + + /** + * Created By : sayli Raut + * Created at : 24 May 2024 + * Use : To get priivacy policy detail. + */ + public function getTermsConditon() + { + try { + $token = readHeaderToken(); + if ($token) { + $customerIamId = $token['sub']; + $response = $this->CMSApiServices->getTermsConditon(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + } else { + return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + } + } catch (\Exception $e) { + Log::error('FAW get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + } diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/ContactUsApiController.php b/app/Http/Controllers/Admin/APIs/Customer_API/ContactUsApiController.php index 52a518c..d2a3454 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/ContactUsApiController.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/ContactUsApiController.php @@ -53,8 +53,8 @@ class ContactUsApiController extends Controller } /** - * Created By : Hritik - * Created at : 30 JAN 2024 + * Created By : Sayli Raut + * Created at : 27 May 2024 * Use : To validate Customer and Restaurant Contact form data */ public function validateContactForm(Request $request) diff --git a/app/Models/IamPrincipal.php b/app/Models/IamPrincipal.php index d7d0c83..55052b6 100644 --- a/app/Models/IamPrincipal.php +++ b/app/Models/IamPrincipal.php @@ -35,6 +35,7 @@ class IamPrincipal extends Authenticatable implements JWTSubject 'profile_photo', 'address_line1', 'user_name', + 'state_xid', 'is_active', 'notification_status', 'deleted_by_admin' diff --git a/app/Models/ManageState.php b/app/Models/ManageState.php new file mode 100644 index 0000000..1f2d916 --- /dev/null +++ b/app/Models/ManageState.php @@ -0,0 +1,11 @@ +where('is_active', 1)->get()->toArray(); + return $data; + } catch (Exception $ex) { + Log::error('List sate Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + public function register($request) { try { @@ -42,13 +55,15 @@ class AuthServices $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 'date_of_birth' => $request->date_of_birth, - 'address_line1' => $request->address_line1, + // 'address_line1' => $request->address_line1, 'phone_number' => $request->phone_number, + 'state_xid' =>$request->state_xid, ]); DB::commit(); diff --git a/app/Services/APIs/CustomerAPIs/CMSApiServices.php b/app/Services/APIs/CustomerAPIs/CMSApiServices.php index 127f774..4c73f1a 100644 --- a/app/Services/APIs/CustomerAPIs/CMSApiServices.php +++ b/app/Services/APIs/CustomerAPIs/CMSApiServices.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Log; use App\Models\Faq; use App\Models\NewsArticle; use App\Models\PrivacyPolicy; +use App\Models\Termsandconditions; use Exception; class CMSApiServices @@ -127,4 +128,20 @@ class CMSApiServices return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + public function getTermsConditon() + { + try { + $data['customer'] = Termsandconditions::select('id', 'message') + ->where('category_xid', '1') + ->get() + ->toArray(); + + return $data; + } catch (Exception $ex) { + Log::error('Terms and condition Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + } diff --git a/database/migrations/2024_05_27_055629_create_manage_states.php b/database/migrations/2024_05_27_055629_create_manage_states.php new file mode 100644 index 0000000..6182c07 --- /dev/null +++ b/database/migrations/2024_05_27_055629_create_manage_states.php @@ -0,0 +1,32 @@ +id(); + $table->string('name'); + $table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired'); + $table->integer('created_by')->nullable(); + $table->integer('modified_by')->nullable(); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('manage_states'); + } +}; diff --git a/routes/customer_api.php b/routes/customer_api.php index 5563924..fb27bcc 100644 --- a/routes/customer_api.php +++ b/routes/customer_api.php @@ -11,6 +11,7 @@ Route::middleware(['customerApiBasicAuth'])->group(function () { Route::post('/v1/check-age', [AuthController::class, 'checkAge']); +Route::get('/v1/list-states', [AuthController::class, 'viewstates']); Route::post('/v1/register', [AuthController::class, 'register']); Route::post('/v1/login', [AuthController::class, 'login']); Route::post('/v1/forgot-password', [AuthController::class, 'forgotPassword']); @@ -26,10 +27,12 @@ Route::get('/v1/list-of-faqs', [CMSApiController::class, 'getfaq']); Route::get('/v1/list-of-about-us', [CMSApiController::class, 'getAboutUs']); Route::get('/v1/list-of-privacy-policy', [CMSApiController::class, 'getPrivacyPolicy']); Route::get('/v1/list-of-news-articles', [CMSApiController::class, 'getNewsArticles']); +Route::get('/v1/list-of-terms-conditions', [CMSApiController::class, 'getTermsConditon']); + //*******************************************************contact us******************************************************** -// Route::post('/v1/contact-us', [ContactUsApiController::class, 'addContactForm']); +Route::post('/v1/contact-us', [ContactUsApiController::class, 'addContactForm']);