From 5d315b07ff61849d31503ce8e3bb75b64f931f04 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Fri, 24 May 2024 13:32:51 +0530 Subject: [PATCH] Cutsomer Register --- .../APIs/Customer_API/AuthController.php | 99 +++++++++++ .../APIs/Customer_API/CMSApiController.php | 108 ++++++++++++ app/Http/Helpers/Imagehelper.php | 162 ++++++++++++++++++ app/Http/Kernel.php | 75 ++++++++ app/Http/Middleware/CustomerApiBasicAuth.php | 49 ++++++ app/Http/Middleware/CustomerJwtMiddleware.php | 46 +++++ app/Models/Aboutus.php | 23 +++ app/Models/Faq.php | 19 ++ app/Models/IamPrincipal.php | 2 +- app/Models/MainCategory.php | 13 ++ app/Models/NewsArticle.php | 18 ++ app/Models/NewsArticleCategory.php | 15 ++ app/Models/PrivacyPolicy.php | 11 ++ app/Providers/RouteServiceProvider.php | 48 ++++++ .../APIs/CustomerAPIs/AuthServices.php | 67 ++++++++ .../APIs/CustomerAPIs/CMSApiServices.php | 130 ++++++++++++++ bootstrap/providers.php | 1 + composer.json | 3 +- .../2024_01_22_065500_create_faqs_table.php | 33 ++++ ...24_01_22_071101_create_aboutuses_table.php | 36 ++++ ...7_create_news_article_categories_table.php | 28 +++ ...1_22_100217_create_news_articles_table.php | 36 ++++ ...3_101343_create_privacy_policies_table.php | 30 ++++ ...23_115225_create_main_categories_table.php | 28 +++ resources/lang/en/auth.php | 4 +- routes/customer_api.php | 30 ++++ 26 files changed, 1111 insertions(+), 3 deletions(-) create mode 100644 app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php create mode 100644 app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php create mode 100644 app/Http/Helpers/Imagehelper.php create mode 100644 app/Http/Kernel.php create mode 100644 app/Http/Middleware/CustomerApiBasicAuth.php create mode 100644 app/Http/Middleware/CustomerJwtMiddleware.php create mode 100644 app/Models/Aboutus.php create mode 100644 app/Models/Faq.php create mode 100644 app/Models/MainCategory.php create mode 100644 app/Models/NewsArticle.php create mode 100644 app/Models/NewsArticleCategory.php create mode 100644 app/Models/PrivacyPolicy.php create mode 100644 app/Providers/RouteServiceProvider.php create mode 100644 app/Services/APIs/CustomerAPIs/AuthServices.php create mode 100644 app/Services/APIs/CustomerAPIs/CMSApiServices.php create mode 100644 database/migrations/2024_01_22_065500_create_faqs_table.php create mode 100644 database/migrations/2024_01_22_071101_create_aboutuses_table.php create mode 100644 database/migrations/2024_01_22_095927_create_news_article_categories_table.php create mode 100644 database/migrations/2024_01_22_100217_create_news_articles_table.php create mode 100644 database/migrations/2024_01_23_101343_create_privacy_policies_table.php create mode 100644 database/migrations/2024_05_23_115225_create_main_categories_table.php create mode 100644 routes/customer_api.php diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php new file mode 100644 index 0000000..ea3f2c3 --- /dev/null +++ b/app/Http/Controllers/Admin/APIs/Customer_API/AuthController.php @@ -0,0 +1,99 @@ +AuthServices = $AuthServices; + } + /** + * Created By : sayli Raut + * Created at : 24 May 2024 + * Use : To check customer age. + */ + public function checkAge(Request $request) + { + try { + $validator = Validator::make($request->all(), [ + 'age' => 'required|string' + ]); + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + Log::error("Login validation error: " . implode(", ", $validationErrors)); + return jsonResponseWithErrorMessageApi($validationErrors, 403); + } + + return $this->AuthServices->checkAge($request); + } catch (\Exception $e) { + return response()->json(['message' => 'Something went wrong.'], 500); + } + } + + /** + * Created By : sayli Raut + * Created at : 25 May 2024 + * Use : Customer Registration. + */ + public function register(Request $request) + { + try { + $validator = Validator::make($request->all(), [ + 'first_name' => 'required|string|min:2|max:100', + 'email_address' => [ + 'required', + 'string', + 'email', + 'max:100', + Rule::unique('iam_principal')->where(function ($query) { + return $query->where('principal_type_xid', 3)->whereNull('deleted_at'); + }), + ], + + 'password' => 'required|string|min:6', + 'confirm_password' => 'required|same:password', + '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.'); + } + }, + ], + 'phone_number' => 'required|min:10', + 'address_line1' => 'required|max:50', + ]); + + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + Log::error("Registation validation error: " . implode(", ", $validationErrors)); + return jsonResponseWithErrorMessageApi($validationErrors, 403); + } + return $this->AuthServices->register($request); + } catch (QueryException $e) { + Log::error('Customer Registration Failed ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403); + } + } +} diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php b/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php new file mode 100644 index 0000000..200e32c --- /dev/null +++ b/app/Http/Controllers/Admin/APIs/Customer_API/CMSApiController.php @@ -0,0 +1,108 @@ +CMSApiServices = $CMSApiServices; + } + + /** + * Created By : sayli Raut + * Created at : 23 May 2024 + * Use : To get faq detail. + */ + public function getfaq() + { + try { + // $token = readHeaderToken(); + + // if ($token) { + // $customerIamId = $token['sub']; + $response = $this->CMSApiServices->getfaq(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + // } else { + // return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + // } + } catch (Exception $e) { + Log::error('FAQ get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + /** + * Created By : sayli Raut + * Created at : 23 May 2024 + * Use : To get about us detail. + */ + public function getAboutUs() + { + try { + // $token = readHeaderToken(); + // if ($token) { + // $customerIamId = $token['sub']; + $response = $this->CMSApiServices->getAboutUs(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + // } else { + // return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + // } + } catch (\Exception $e) { + Log::error('Abot us get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + /** + * Created By : sayli Raut + * Created at : 24 May 2024 + * Use : To get privacy policy detail. + */ + public function getPrivacyPolicy() + { + try { + // $token = readHeaderToken(); + // if ($token) { + // $customerIamId = $token['sub']; + $response = $this->CMSApiServices->getPrivacyPolicy(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + // } else { + // return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + // } + } catch (\Exception $e) { + Log::error('Privacy policy get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + /** + * Created By : sayli Raut + * Created at : 24 May 2024 + * Use : To get News and Articles detail. + */ + public function getNewsArticles() + { + try { + // $token = readHeaderToken(); + // if ($token) { + // $customerIamId = $token['sub']; + $response = $this->CMSApiServices->getNewsArticles(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + // } else { + // return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + // } + } catch (\Exception $e) { + Log::error('News and articles data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + +} diff --git a/app/Http/Helpers/Imagehelper.php b/app/Http/Helpers/Imagehelper.php new file mode 100644 index 0000000..3cd4daa --- /dev/null +++ b/app/Http/Helpers/Imagehelper.php @@ -0,0 +1,162 @@ +extension(); + $name = time() . '.' . $file->getClientOriginalExtension(); + $originalImageName = $type . '_' . $id . '_' . $sub_id . '_' . $name ; + //if image already exist unlink that image + $path = public_path() . '/uploads/' . $type . '/' . $originalImageName; + // if(File::exists($path)) { + // unlink($path); + // } + $file->storeAs($actualImagePath, $originalImageName, 'public'); + $sub_id++; + $imagePath[] = $originalImageName; + } + return $imagePath; + } +} + +/** + * Created By : Pradyumn Dwivedi + * Created at : 06 November 2023 + * Use : To upload single image without crop + */ +if (!function_exists('saveSingleImageWithoutCrop')) { + function saveSingleImageWithoutCrop($image, $path, $image_db = null) + { + $thumbnail = ''; + + if (!empty($image)) { + // Define the folder path where the image will be stored + $folderPath = storage_path('app/public/uploads/' . $path . '/'); + + // Generate a unique image name + $imageName = uniqid() . '.png'; + + // Move the uploaded image to the specified folder + $image->move($folderPath, $imageName); + + // If there was a previous image, delete it + if (!empty($image_db)) { + $previousImagePath = $folderPath . $image_db; + if (file_exists($previousImagePath)) { + unlink($previousImagePath); + } + } + + $thumbnail = $imageName; + } elseif (!empty($image_db)) { + $thumbnail = $image_db; + } + + return $thumbnail; + } +} + +/** + * Created By : Pradyumn Dwivedi + * Created at : 06 November 2023 + * Use : Function for listing image url + */ + + if (!function_exists('VendorListingIconUrl')) { + function VendorListingIconUrl($type, $imageName) + { + $src = ''; + $defaultImagePath = ""; + + if (!empty($imageName) && file_exists('public/vendor/' . $type . '/' . $imageName)) { + $src = 'public/vendor/' . $type . '/' . $imageName . '?d=' . time(); + } else { + $src = "public/admin/assets/media/wedzy/default_img.jpg?d=" . time(); + } + return url($src); + } +} + + +/** + * Created By : Chandan Yadav + * Created at : 12 Jan 2024 + * Use : Function for listing image url + */ + if (!function_exists('DuoListingIconUrl')) { + function DuoListingIconUrl($type, $imageName) + { + $src = ''; + $defaultImagePath = ""; + + if (!empty($imageName) && file_exists('public/duo/' . $type . '/' . $imageName)) { + $src = 'public/duo/' . $type . '/' . $imageName . '?d=' . time(); + } else { + $src = "public/admin/assets/media/wedzy/default_img.jpg?d=" . time(); + } + return url($src); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php new file mode 100644 index 0000000..52fd40f --- /dev/null +++ b/app/Http/Kernel.php @@ -0,0 +1,75 @@ + + */ + protected $middleware = [ + // \App\Http\Middleware\TrustHosts::class, + // \App\Http\Middleware\TrustProxies::class, + \Illuminate\Http\Middleware\HandleCors::class, + // \App\Http\Middleware\PreventRequestsDuringMaintenance::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + // \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array> + */ + protected $middlewareGroups = [ + 'web' => [ + // \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + // \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + ]; + + /** + * The application's middleware aliases. + * + * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. + * + * @var array + */ + protected $middlewareAliases = [ + 'checkStatus' => \App\Http\Middleware\CheckStatus::class, + // 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + // 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, + // 'signed' => \App\Http\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + + 'customerApiBasicAuth' => \App\Http\Middleware\CustomerApiBasicAuth::class, + // 'restaurantApiBasicAuth' => \App\Http\Middleware\RestaurantApiBasicAuth::class, + 'customer.jwt.verify' => \App\Http\Middleware\CustomerJwtMiddleware::class, + // 'restaurant.jwt.verify' => \App\Http\Middleware\RestaurantJwtMiddleware::class, + + ]; +} diff --git a/app/Http/Middleware/CustomerApiBasicAuth.php b/app/Http/Middleware/CustomerApiBasicAuth.php new file mode 100644 index 0000000..4298c58 --- /dev/null +++ b/app/Http/Middleware/CustomerApiBasicAuth.php @@ -0,0 +1,49 @@ +header('Accept-Language'); + if ($locale) { + app()->setLocale($locale); + } + + $authorizedUsers = [ + 'CheersCustomer' => '71%@L%es^bUX94`J9XT*@bh,._WWM{', // Replace with actual credentials + ]; + + $authUser = $request->getUser(); + $authPass = $request->getPassword(); + + if (!isset($authorizedUsers[$authUser]) || $authorizedUsers[$authUser] !== $authPass) { + return response()->json([ + 'error' => 'Authorization Required', + 'message' => 'Access denied' + ], 401); + } + + $lang = $request->header('Accept-Language', null); + if (!empty($lang)) { + app()->setLocale($lang); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/CustomerJwtMiddleware.php b/app/Http/Middleware/CustomerJwtMiddleware.php new file mode 100644 index 0000000..4c747a7 --- /dev/null +++ b/app/Http/Middleware/CustomerJwtMiddleware.php @@ -0,0 +1,46 @@ +hasHeader('access-token')) { + return response()->json(['status' => 'error', 'status_code' => 401, 'message' => 'Access token not provided'], 401); + } + + // Retrieve the token from the custom access-token header + $token = $request->header('access-token'); + + try { + // Attempt to authenticate the user based on the token + $user = JWTAuth::setToken($token)->authenticate(); + + // Check if authentication was successful and user type is correct + if (!$user || $user->principal_type_xid !== 3) { + return response()->json(['status' => 'error', 'status_code' => 401, 'message' => 'Unauthorized access'], 401); + } + + Session::flash('vendorToken', $token); + } catch (JWTException $e) { + return response()->json(['status' => 'error', 'status_code' => 401, 'message' => 'Invalid token'], 401); + } + + return $next($request); + } +} diff --git a/app/Models/Aboutus.php b/app/Models/Aboutus.php new file mode 100644 index 0000000..8a64946 --- /dev/null +++ b/app/Models/Aboutus.php @@ -0,0 +1,23 @@ +belongsTo(MainCategory::class,'category_xid','id'); + } +} diff --git a/app/Models/Faq.php b/app/Models/Faq.php new file mode 100644 index 0000000..f481246 --- /dev/null +++ b/app/Models/Faq.php @@ -0,0 +1,19 @@ +belongsTo(MainCategory::class, 'faq_category_id', 'id'); + } +} diff --git a/app/Models/IamPrincipal.php b/app/Models/IamPrincipal.php index f4a72e1..0847fce 100644 --- a/app/Models/IamPrincipal.php +++ b/app/Models/IamPrincipal.php @@ -5,8 +5,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Laravel\Sanctum\HasApiTokens; use Illuminate\Notifications\Notifiable; -use Illuminate\Database\Eloquent\Model; use Tymon\JWTAuth\Contracts\JWTSubject; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\admin\ManageFeedback; use App\Models\admin\ManageModuleLink; diff --git a/app/Models/MainCategory.php b/app/Models/MainCategory.php new file mode 100644 index 0000000..a2be067 --- /dev/null +++ b/app/Models/MainCategory.php @@ -0,0 +1,13 @@ +belongsTo(NewsArticleCategory::class,'news_articles_category_xid','id'); + } +} diff --git a/app/Models/NewsArticleCategory.php b/app/Models/NewsArticleCategory.php new file mode 100644 index 0000000..49d87a3 --- /dev/null +++ b/app/Models/NewsArticleCategory.php @@ -0,0 +1,15 @@ +hasMany(NewsArticle::class,'news_article_categories','id'); + } +} diff --git a/app/Models/PrivacyPolicy.php b/app/Models/PrivacyPolicy.php new file mode 100644 index 0000000..1b23ff7 --- /dev/null +++ b/app/Models/PrivacyPolicy.php @@ -0,0 +1,11 @@ +by($request->user()?->id ?: $request->ip()); + }); + + $this->routes(function () { + Route::middleware('api') + ->prefix('api') + ->group(base_path('routes/api.php')); + + //Created by : Hritik; Created at : 29 Jan 2024; Use : custom Customer api; + Route::middleware('api') + ->prefix('customer_api') + ->group(base_path('routes/customer_api.php')); + // Route::middleware('api') + // ->prefix('restaurant_api') + // ->group(base_path('routes/restaurant_api.php')); + + Route::middleware('web') + ->group(base_path('routes/web.php')); + }); + } +} diff --git a/app/Services/APIs/CustomerAPIs/AuthServices.php b/app/Services/APIs/CustomerAPIs/AuthServices.php new file mode 100644 index 0000000..09106d0 --- /dev/null +++ b/app/Services/APIs/CustomerAPIs/AuthServices.php @@ -0,0 +1,67 @@ +input('age'); + if ($age == 'yes') { + return jsonResponseWithSuccessMessage(__('auth.legally_21'), 200); + } else { + return jsonResponseWithErrorMessageApi(__('auth.not_legally_21'), 403); + } + } catch (Exception $ex) { + Log::error('Check age service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + public function register($request) + { + dd($request); + try { + DB::beginTransaction(); + $user = IamPrincipal::create([ + 'one_signal_player_id' => $request->one_signal_player_id, + 'first_name' => $request->first_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, + 'phone_number' => $request->phone_number, + ]); + DB::commit(); + + $token = auth()->login($user); + + $response = [ + 'iam_principal_xid' => $user->id, + 'access_token' => $token, + 'token_type' => 'bearer', + ]; + return jsonResponseWithSuccessMessage(__('auth.Rest_user_created'), $response, 200); + } catch (QueryException $e) { + DB::rollBack(); + Log::error('Restaurant Registration Failed ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403); + } + } + +} diff --git a/app/Services/APIs/CustomerAPIs/CMSApiServices.php b/app/Services/APIs/CustomerAPIs/CMSApiServices.php new file mode 100644 index 0000000..127f774 --- /dev/null +++ b/app/Services/APIs/CustomerAPIs/CMSApiServices.php @@ -0,0 +1,130 @@ +where([['is_active', '1'], ['faq_category_id', '1']]) + ->get() + ->toArray(); + + $data['restaurant'] = Faq::select('id', 'question', 'answers') + ->where([['is_active', '1'], ['faq_category_id', '2']]) + ->get() + ->toArray(); + + return $data; + } catch (Exception $ex) { + Log::error('Faq Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + public function getAboutUs() + { + try { + $data['customer'] = Aboutus::select('id', 'title', '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', 'title', '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']); + } + + foreach ($data['restaurant'] as $k => $val) { + $data['restaurant'][$k]['thumbnail_image'] = ListingImageUrl('about_images', $val['thumbnail_image']); + } + + return $data; + } catch (Exception $ex) { + Log::error('About us Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + public function getPrivacyPolicy() + { + try { + $data['customer'] = PrivacyPolicy::select('id', 'description') + ->where('category_xid', '1') + ->get() + + ->toArray(); + + $data['restaurant'] = PrivacyPolicy::select('id', 'description') + ->where('category_xid', '2') + ->get() + + ->toArray(); + return $data; + } catch (Exception $ex) { + Log::error('Privacy policy Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } + + public function getNewsArticles() + { + try { + $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']); + return $item; + }) + ->toArray(); + + $data['restaurant'] = NewsArticle::select('id', 'name', 'description', 'thumbnail_image', 'image') + ->where([['is_active', '1'], ['news_articles_category_xid', '2']]) + ->get() + ->map(function ($item) { + $item['description'] = strip_tags($item['description']); + return $item; + }) + ->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']); + } + + //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']); + } + + return $data; + } catch (Exception $ex) { + Log::error('News and articles Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } +} diff --git a/bootstrap/providers.php b/bootstrap/providers.php index 55e8e15..27e9944 100644 --- a/bootstrap/providers.php +++ b/bootstrap/providers.php @@ -4,4 +4,5 @@ return [ App\Providers\AppServiceProvider::class, App\Providers\FortifyServiceProvider::class, App\Providers\JetstreamServiceProvider::class, + App\Providers\RouteServiceProvider::class, ]; diff --git a/composer.json b/composer.json index 12aa3b1..c1e4d6f 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "Database\\Seeders\\": "database/seeders/" }, "files": [ - "app/Http/Helpers/Webhelper.php" + "app/Http/Helpers/Webhelper.php", + "app/Http/Helpers/Imagehelper.php" ] }, "autoload-dev": { diff --git a/database/migrations/2024_01_22_065500_create_faqs_table.php b/database/migrations/2024_01_22_065500_create_faqs_table.php new file mode 100644 index 0000000..8f01d1c --- /dev/null +++ b/database/migrations/2024_01_22_065500_create_faqs_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('faq_category_id'); + $table->foreign('faq_category_id')->references('id')->on('main_categories'); + $table->longText('question')->nullable(); + $table->longText('answers')->nullable(); + $table->enum('is_active', ['0', '1'])->comment('0 = Inactive, 1 = Active'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('faqs'); + } +}; diff --git a/database/migrations/2024_01_22_071101_create_aboutuses_table.php b/database/migrations/2024_01_22_071101_create_aboutuses_table.php new file mode 100644 index 0000000..61b4f45 --- /dev/null +++ b/database/migrations/2024_01_22_071101_create_aboutuses_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('title'); + $table->string('thumbnail_image'); + $table->unsignedBigInteger('category_xid'); + $table->foreign('category_xid')->references('id')->on('main_categories'); + $table->longText('description'); + $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('aboutuses'); + } +}; diff --git a/database/migrations/2024_01_22_095927_create_news_article_categories_table.php b/database/migrations/2024_01_22_095927_create_news_article_categories_table.php new file mode 100644 index 0000000..791e10e --- /dev/null +++ b/database/migrations/2024_01_22_095927_create_news_article_categories_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('news_article_categories'); + } +}; 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 new file mode 100644 index 0000000..3135cb8 --- /dev/null +++ b/database/migrations/2024_01_22_100217_create_news_articles_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('news_articles_category_xid'); + $table->foreign('news_articles_category_xid')->references('id')->on('news_article_categories'); + $table->string('name'); + $table->longText('description'); + $table->string('thumbnail_image'); + $table->string('image'); + $table->enum('is_active',['0','1'])->comment('0 = Active, 1 = Inactive'); + $table->softDeletes(); + $table->timestamps(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('news_articles'); + } +}; diff --git a/database/migrations/2024_01_23_101343_create_privacy_policies_table.php b/database/migrations/2024_01_23_101343_create_privacy_policies_table.php new file mode 100644 index 0000000..ab643c0 --- /dev/null +++ b/database/migrations/2024_01_23_101343_create_privacy_policies_table.php @@ -0,0 +1,30 @@ +id(); + $table->unsignedBigInteger('category_xid'); + $table->foreign('category_xid')->references('id')->on('main_categories'); + $table->longtext('description')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('privacy_policies'); + } +}; diff --git a/database/migrations/2024_05_23_115225_create_main_categories_table.php b/database/migrations/2024_05_23_115225_create_main_categories_table.php new file mode 100644 index 0000000..8106008 --- /dev/null +++ b/database/migrations/2024_05_23_115225_create_main_categories_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('main_categories'); + } +}; diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 10df0f3..f60c6e6 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -100,6 +100,8 @@ return [ 'invalid_redemption_date' => 'The redemption date is not valid', 'users_imported' => 'Users imported successfully', 'deleted_user_by_admin' => 'User deleted by admin', - 'otp_expired_invalid' => 'Invalid OTP or expired.' + 'otp_expired_invalid' => 'Invalid OTP or expired.', + 'legally_21' => 'You are legally over the age of 21. Proceed to the next page.', + 'not_legally_21' => 'Sorry, you are not legally over the age of 21. Exit the page.', ]; diff --git a/routes/customer_api.php b/routes/customer_api.php new file mode 100644 index 0000000..681ef92 --- /dev/null +++ b/routes/customer_api.php @@ -0,0 +1,30 @@ +group(function () { + + +Route::post('/v1/check-age', [AuthController::class, 'checkAge']); +Route::post('/v1/register', [AuthController::class, 'register']); +Route::post('/v1/login', [AuthController::class, 'login']); +Route::post('/v1/forgot-password', [AuthController::class, 'forgotPassword']); +Route::post('/v1/password/verify-otp', [AuthController::class, 'verifyOtpForgotPassword']); + +//*******************************************************CMS******************************************************** + +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']); + + + + + + +// });