Merge pull request #3 from WDI-Ideas/sayli

Sayli
This commit is contained in:
Sayli Raut
2024-05-24 13:33:37 +05:30
committed by GitHub
26 changed files with 1111 additions and 3 deletions

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Http\Controllers\Admin\APIs\Customer_API;
use App\Http\Controllers\Controller;
use App\Services\APIs\CustomerAPIs\AuthServices;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\QueryException;
use App\Models\IamPrincipal;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
class AuthController extends Controller
{
protected $AuthServices;
public function __construct(AuthServices $AuthServices)
{
$this->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);
}
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers\Admin\APIs\Customer_API;
use App\Http\Controllers\Controller;
use App\Services\APIs\CustomerAPIs\CMSApiServices;
use Illuminate\Http\Request;
use Exception;
use Illuminate\Support\Facades\Log;
class CMSApiController extends Controller
{
protected $CMSApiServices;
public function __construct(CMSApiServices $CMSApiServices)
{
$this->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);
}
}
}

View File

@@ -0,0 +1,162 @@
<?php
use Illuminate\Support\Facades\Storage;
use Image as thumbimage;
/**
* Created by : Pradyumn Dwivedi
* Created On : 06 November 2023
* Uses : To upload single image after crop
*/
if (!function_exists('singleImageUpload')) {
function singleImageUpload($image, $path, $image_db = null)
{
$thumbnail = '';
if (!empty($image)) {
$folderPath = 'storage/app/public/uploads/' . $path . '/';
$image_parts = explode(";base64,", $image);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = base64_decode($image_parts[1]);
$imageName = uniqid() . '.png';
$imageFullPath = $folderPath . $imageName;
if (isset($image_db) && !empty($image_db)) {
unlink($folderPath . '/' . $image_db);
}
file_put_contents($imageFullPath, $image_base64);
$thumbnail = $imageName;
} else {
$thumbnail = $image_db;
}
return $thumbnail;
}
}
/**
* Created By : Pradyumn Dwivedi
* Created at : 06 November 2023
* Use : Function for listing image url
*/
if (!function_exists('ListingImageUrl')) {
function ListingImageUrl($type, $imageName)
{
$src = '';
$defaultImagePath = "";
if (!empty($imageName) && file_exists('storage/app/public/uploads/' . $type . '/' . $imageName)) {
$src = 'storage/app/public/uploads/' . $type . '/' . $imageName . '?d=' . time();
} else {
$src = "storage/app/public" . '/' . $imageName;
}
return url($src);
}
}
/**
* Created By : Pradyumn Dwivedi
* Created at : 13 March 2023
* Use : To upload multiple image without crop
*/
if (!function_exists('saveMultipleImage')) {
function saveMultipleImage($files, $type = "", $id = "", $sub_id = "")
{
//sort images array by name
// sort($files);
foreach ($files as $file) {
$actualImagePath = 'uploads/' . $type;
$extension = $file->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);
}
}

75
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,75 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
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<string, array<int, class-string|string>>
*/
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<string, class-string|string>
*/
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,
];
}

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class CustomerApiBasicAuth
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
/**
* Created By : sayli raut
* Created at : 31 Jan 2024
* Use : To validate request before sending response
*/
$locale = $request->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);
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Tymon\JWTAuth\Facades\JWTAuth;
use Exception;
use Illuminate\Support\Facades\Session;
use Tymon\JWTAuth\Exceptions\JWTException;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class CustomerJwtMiddleware
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
// Check if the custom access-token header is present
if (!$request->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);
}
}

23
app/Models/Aboutus.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use App\Models\MainCategory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Aboutus extends Model
{
use HasFactory;
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = "about_us";
public function category()
{
return $this->belongsTo(MainCategory::class,'category_xid','id');
}
}

19
app/Models/Faq.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Faq extends Model
{
use HasFactory;
protected $table = 'faqs';
protected $fillable = ['question', 'answers', 'faq_category_id'];
public function faqCategory()
{
return $this->belongsTo(MainCategory::class, 'faq_category_id', 'id');
}
}

View File

@@ -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;

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MainCategory extends Model
{
use HasFactory;
protected $table = 'main_categories';
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class NewsArticle extends Model
{
use HasFactory;
use SoftDeletes;
public function category()
{
return $this->belongsTo(NewsArticleCategory::class,'news_articles_category_xid','id');
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class NewsArticleCategory extends Model
{
use HasFactory;
public function newsandarticle()
{
return $this->hasMany(NewsArticle::class,'news_article_categories','id');
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PrivacyPolicy extends Model
{
use HasFactory;
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
use Illuminate\Cache\RateLimiting\Limit;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*/
public function boot(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->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'));
});
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Services\APIs\CustomerAPIs;
use App\Models\IamAppAction;
use App\Models\IamPrincipal;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\QueryException;
use Exception;
class AuthServices
{
public function checkAge($request)
{
try {
$age = $request->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);
}
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace App\Services\APIs\CustomerAPIs;
use App\Models\Aboutus;
use Illuminate\Support\Facades\Log;
use App\Models\Faq;
use App\Models\NewsArticle;
use App\Models\PrivacyPolicy;
use Exception;
class CMSApiServices
{
public function getfaq()
{
try {
$data['customer'] = Faq::select('id', 'question', 'answers')
->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);
}
}
}

View File

@@ -4,4 +4,5 @@ return [
App\Providers\AppServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\Providers\RouteServiceProvider::class,
];

View File

@@ -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": {

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('faqs', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('about_us', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('news_article_categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('news_article_categories');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('news_articles', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('privacy_policies', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('main_categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('main_categories');
}
};

View File

@@ -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.',
];

30
routes/customer_api.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
use App\Http\Controllers\Admin\APIs\Customer_API\AuthController;
use App\Http\Controllers\Admin\APIs\Customer_API\CMSApiController;
use Illuminate\Support\Facades\Route;
// Route::middleware(['customerApiBasicAuth'])->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']);
// });