This commit is contained in:
Hritikkk9
2024-07-16 12:17:23 +05:30
18 changed files with 1702 additions and 956 deletions

View File

@@ -29,7 +29,9 @@ class DashboardExportUser implements FromArray, WithHeadings
'Subscription Period Start' => Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A'),
'Subscription Period End' => Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A'),
'Next Payment Date' => Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A'),
// 'Subscription Period Start' => $transaction['current_period_start'],
// 'Subscription Period End' => $transaction['current_period_end'],
// 'Next Payment Date' => $transaction['next_payment_date'],
];
}, $this->data);
}

View File

@@ -0,0 +1,184 @@
<?php
namespace App\Exports;
use App\Models\IamPrincipal;
use App\Models\RedeemRestaurant;
use App\Models\Subscriptions;
use App\Models\ReferralUsers;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class ExportReports implements FromView
{
protected $reportType;
protected $states;
protected $startDate;
protected $endDate;
protected $restaurants;
public function __construct($reportType, $states, $startDate, $endDate, $restaurants = [])
{
$this->reportType = $reportType;
$this->states = $states;
$this->startDate = $startDate;
$this->endDate = $endDate;
$this->restaurants = $restaurants;
}
public function view(): View
{
$data = collect();
if ($this->reportType === 'Total Subscribed') {
$query = Subscriptions::query();
if (!empty($this->states)) {
$query->whereHas('iamPrincipal', function ($q) {
$q->whereIn('state_xid', $this->states);
});
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
// dd($data);
} elseif ($this->reportType === 'Total Users') {
$query = IamPrincipal::query()->where('principal_type_xid',3);
if (!empty($this->states)) {
$query->whereIn('state_xid', $this->states);
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
} elseif ($this->reportType === 'Redemptions') {
$query = RedeemRestaurant::with(['restaurant', 'customer'])->where('is_redeem', 0);
if (!empty($this->states)) {
$query->whereHas('customer', function ($q) {
$q->whereIn('state_xid', $this->states);
});
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
} elseif ($this->reportType === 'Redemptions for Specific Restaurants') {
$query = RedeemRestaurant::with('restaurant', 'customer');
if (!empty($this->restaurants)) {
$query->whereIn('manage_restaurants_xid', $this->restaurants);
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
} elseif ($this->reportType === 'Subscriptions Cancelled') {
$query = Subscriptions::query()->where('is_cancelled_subscription', 1);
if (!empty($this->states)) {
$query->whereHas('iamPrincipal', function ($q) {
$q->whereIn('state_xid', $this->states);
});
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
}
elseif ($this->reportType === 'Subscriptions Cancelled') {
$query = Subscriptions::with('iamPrincipal')->where('is_cancelled_subscription', 1);
if (!empty($this->states)) {
$query->whereHas('iamPrincipal', function ($q) {
$q->whereIn('state_xid', $this->states);
});
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
}
elseif ($this->reportType === 'Referrals Made') {
$query = ReferralUsers::query()
->with(['referredUser', 'referredUser.state'])
->whereHas('referredUser', function ($query) {
$query->whereIn('state_xid', $this->states);
});
if (!empty($this->startDate)) {
$query->whereDate('referred_date_time', '>=', $this->startDate);
}
if (!empty($this->endDate)) {
$query->whereDate('referred_date_time', '<=', $this->endDate);
}
$data = $query->get();
}
elseif ($this->reportType === 'Referees Joined') {
$query = ReferralUsers::query()
->with(['refeersUser', 'refeersUser.state'])
->whereHas('refeersUser', function ($query) {
$query->whereIn('state_xid', $this->states);
});
if (!empty($this->startDate)) {
$query->whereDate('referred_date_time', '>=', $this->startDate);
}
if (!empty($this->endDate)) {
$query->whereDate('referred_date_time', '<=', $this->endDate);
}
$data = $query->get();
}
return view('exports.reports', [
'data' => $data,
'reportType' => $this->reportType
]);
return $data;
}
}

View File

@@ -9,7 +9,7 @@ use App\Models\ReferralUsers;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class ReportExport implements FromView
class ReportExports implements FromView
{
protected $reportType;
protected $states;
@@ -48,6 +48,7 @@ class ReportExport implements FromView
}
$data = $query->get();
// dd($data);
} elseif ($this->reportType === 'Total Users') {
$query = IamPrincipal::query()->where('principal_type_xid',3);

View File

@@ -187,4 +187,29 @@ class CustomerControllerApi extends Controller
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
/**
* Created By : sayli Raut
* Created at : 15 July 2024
* Use : To get user subscription status.
*/
public function CheckSubscription()
{
try {
$token = readHeaderToken();
if ($token) {
$customerIamId = $token['sub'];
$response = $this->CustomerApiServices->CheckSubscription($customerIamId);
return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), ['is_subscribed' => $response], 200);
} else {
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
}
} catch (Exception $e) {
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
}

View File

@@ -86,178 +86,184 @@ class ManageNotificationsController extends Controller
* Use : To add notification .
*/
public function store_notificaton_data(Request $request)
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
public function store_notificaton_data(Request $request)
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
DB::beginTransaction();
DB::beginTransaction();
if (isset($request->image)) {
$image = $request->image;
$image_db = null;
} else {
$image = null;
$image_db = $request->image;
}
if (isset($request->image)) {
$image = $request->image;
$image_db = null;
} else {
$image = null;
$image_db = $request->image;
}
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
$states = $request->states;
$states = $request->states;
$dateTime = now();
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
$iamPrincipals = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->get();
$dateTime = now();
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
$iamPrincipals = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->get();
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
->where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->whereIn('state_xid', $states)
->get();
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
->where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->whereIn('state_xid', $states)
->get();
if ($request->user_type == 1) {
$allCustomerOneSignalIds = $subscribe->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
$scheduled = false;
foreach ($UserData as $customerIdItem) {
// user_type 1 = subscribed user
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $customerIdItem->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
if ($request->user_type == 1) {
$allCustomerOneSignalIds = $subscribe->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
]);
} else {
// Immediate Notification
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
}
}
} elseif ($request->user_type == 2) {
//user_type 2 unsubscribed users
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)
->pluck('id');
foreach ($UserData as $customerIdItem) {
// user_type 1 = subscribed user
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $customerIdItem->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
]);
$scheduled = true;
} else {
// Immediate Notification
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
}
}
} elseif ($request->user_type == 2) {
// user_type 2 unsubscribed users
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)
->pluck('id');
$subscribedIds = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->pluck('iam_principal_xid');
$subscribedIds = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->pluck('iam_principal_xid');
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
->where('is_active', 1)
->where('notification_status', 1)
->whereIn('state_xid', $states)
->get();
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
->where('is_active', 1)
->where('notification_status', 1)
->whereIn('state_xid', $states)
->get();
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
foreach ($restaurantData as $restaurantsData) {
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $restaurantsData->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
foreach ($restaurantData as $restaurantsData) {
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $restaurantsData->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
]);
$scheduled = true;
} else {
// Immediate Notification
if ($restaurantsData->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$restaurantsData->one_signal_player_id,
$request->title,
$request->description,
$request->title,
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
}
}
} elseif ($request->user_type == 3) {
// user_type 3 = subscribed and unsubscribed users
$userQuery = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->whereIn('state_xid', $states);
$allUserOneSignalIds = $userQuery->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
]);
} else {
// Immediate Notification
if ($restaurantsData->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$restaurantsData->one_signal_player_id,
$request->title,
$request->description,
$request->title,
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
}
}
} elseif ($request->user_type == 3) {
// user_type 3 = subscribed and unsubscribed users
$userQuery = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->whereIn('state_xid', $states);
foreach ($UserData as $CustomerData) {
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $CustomerData->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
]);
$scheduled = true;
} else {
// Immediate Notification
if ($CustomerData->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$CustomerData->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
}
}
}
$allUserOneSignalIds = $userQuery->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
DB::commit();
foreach ($UserData as $CustomerData) {
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
// Scheduled Notification
NotificationDetails::create([
'principal_xid' => $CustomerData->id,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'is_active' => 0,
if ($scheduled) {
return jsonResponseWithSuccessMessage(__('success.save_data_scheduled'));
} else {
return jsonResponseWithSuccessMessage(__('success.save_data_immediate'));
}
} catch (Exception $e) {
DB::rollBack();
Log::error("Notification send Failed " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
]);
} else {
// Immediate Notification
if ($CustomerData->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$CustomerData->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
}
}
}
DB::commit();
return jsonResponseWithSuccessMessage(__('success.save_data'));
} catch (Exception $e) {
DB::rollBack();
Log::error("Notification send Failed " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}

View File

@@ -7,10 +7,10 @@ use Illuminate\Http\Request;
use App\Models\ManageState;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ReportExport;
use App\Exports\ReportExports;
use App\Models\ManageRestaurant;
use App\Models\ReferralUsers;
use App\Exports\ExportReports;
class ManageReportsController extends Controller
{
@@ -41,8 +41,39 @@ class ManageReportsController extends Controller
* Use : To download the excel.
*/
public function exportReports(Request $request)
// public function exportReports(Request $request)
// {
// $reportType = $request->input('reportType');
// $states = $request->input('states');
// $restaurants = $request->input('restaurants', []);
// $startDate = $request->input('startDate');
// $endDate = $request->input('endDate');
// return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx');
// }
// public function exportReports(Request $request)
// {
// // dd($request->all());
// $reportType = $request->input('reportType');
// $states = $request->input('states');
// $restaurants = $request->input('restaurants', []);
// $startDate = $request->input('startDate');
// $endDate = $request->input('endDate');
// try {
// return Excel::download(new ReportExports($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx');
// } catch (\Exception $e) {
// // Log the error for debugging
// \Log::error('Export failed: ' . $e->getMessage());
// return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
// }
// }
public function exportReport(Request $request)
{
// dd($request->all());
$reportType = $request->input('reportType');
$states = $request->input('states');
$restaurants = $request->input('restaurants', []);
@@ -50,9 +81,14 @@ public function exportReports(Request $request)
$startDate = $request->input('startDate');
$endDate = $request->input('endDate');
return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx');
try {
return Excel::download(new ExportReports($reportType, $states, $startDate, $endDate, $restaurants), 'reports.Xlsx');
} catch (\Exception $e) {
\Log::error('Export failed: ' . $e->getMessage());
\Log::error('Stack trace: ' . $e->getTraceAsString());
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
}
}
}

View File

@@ -12,43 +12,43 @@ use Illuminate\Support\Facades\DB;
class CustomerApiServices
{
public function getUserProfileDetailService($customerIamId)
{
try {
$user = IamPrincipal::findOrFail($customerIamId);
{
try {
$user = IamPrincipal::findOrFail($customerIamId);
$data = IamPrincipal::select(
'id',
'first_name',
'last_name',
'email_address',
'phone_number',
'date_of_birth',
'state_xid',
'profile_photo',
'referral_code'
)->find($user->id);
$data = IamPrincipal::select(
'id',
'first_name',
'last_name',
'email_address',
'phone_number',
'date_of_birth',
'state_xid',
'profile_photo',
'referral_code'
)->find($user->id);
$dateTime = now();
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
$dateTime = now();
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId)
->where('next_payment_date', '>=', $formattedDateTime)
->exists();
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId)
->where('next_payment_date', '>=', $formattedDateTime)
->exists();
if ($data->profile_photo) {
$data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo);
} else {
$data->profile_photo = asset('public/assets/img/blankProfile.png');
if ($data->profile_photo) {
$data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo);
} else {
$data->profile_photo = asset('public/assets/img/blankProfile.png');
}
$data->is_subscribed = $isSubscribedUser;
return $data;
} catch (Exception $ex) {
Log::error('Customer Get data service failed : ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
$data->is_subscribed = $isSubscribedUser;
return $data;
} catch (Exception $ex) {
Log::error('Customer Get data service failed : ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
@@ -143,4 +143,21 @@ class CustomerApiServices
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
public function CheckSubscription($customerIamId)
{
try {
$dateTime = now();
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId)
->where('next_payment_date', '>=', $formattedDateTime)
->exists();
return $isSubscribedUser;
} catch (Exception $ex) {
Log::error('Customer subscription Get data service failed : ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
}

View File

@@ -14,8 +14,13 @@ use App\Models\RestaurantTimeInterval;
use App\Models\TimeInterval;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Promise;
use GuzzleHttp\Promise\Utils;
class RestaurantApiServices
@@ -23,29 +28,92 @@ class RestaurantApiServices
public function getCoordinates($customerIamId)
{
try {
$restaurants = ManageRestaurant::with('operatingHours')->select(
'id',
'name',
'image',
'address',
'short_id',
'latitude',
'longtitude'
)
->where('is_active', '1')
->get()
->toArray();
// $perPage = request()->get('per_page', 10000);
$restaurants = ManageRestaurant::with('closedRestaurant')
->select(
'id',
'name',
'image',
'address',
'short_id',
'latitude',
'longtitude'
)
->where('is_active', '1')->get();
$client = new Client();
$promises = [];
$googlePlaceApiKey = config('constants.googlePlaces.api_key');
foreach ($restaurants as &$restaurant) {
$restaurant['image'] = ListingImageUrl('restaurant_images', $restaurant['image']);
$isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
->where('restaurant_xid', $restaurant['id'])
->exists();
$restaurant['is_favourite'] = $isFavourite;
// $restaurant['operating_hours'] = getOpeningHoursOfRestaurant($restaurant['name']);// will update later
$cacheKey = 'restaurant_hours_' . $restaurant['name'];
if (Cache::has($cacheKey)) {
$restaurant['operating_hours'] = Cache::get($cacheKey);
} else {
// Prepare the first request to get the place_id
$promises[$restaurant['name']] = $client->getAsync('https://maps.googleapis.com/maps/api/place/findplacefromtext/json', [
'query' => [
'fields' => 'place_id',
'input' => $restaurant['name'],
'inputtype' => 'textquery',
'key' => $googlePlaceApiKey
]
]);
}
}
// Execute all the first requests concurrently
$results = Utils::settle($promises)->wait();
$detailPromises = [];
foreach ($restaurants as &$restaurant) {
if (isset($results[$restaurant['name']]['value'])) {
$response = $results[$restaurant['name']]['value'];
$placeData = json_decode($response->getBody(), true);
if (isset($placeData['candidates'][0]['place_id'])) {
$placeId = $placeData['candidates'][0]['place_id'];
// Prepare the second request to get the operating hours
$detailPromises[$restaurant['name']] = $client->getAsync('https://maps.googleapis.com/maps/api/place/details/json', [
'query' => [
'fields' => 'opening_hours',
'place_id' => $placeId,
'key' => $googlePlaceApiKey
]
]);
} else {
$restaurant['operating_hours'] = "N/A";
}
}
}
// Execute all the second requests concurrently
$detailResults = Utils::settle($detailPromises)->wait();
foreach ($restaurants as &$restaurant) {
if (isset($detailResults[$restaurant['name']]['value'])) {
$response = $detailResults[$restaurant['name']]['value'];
$data = json_decode($response->getBody(), true);
if (isset($data['result']['opening_hours']['weekday_text'])) {
$hours = $data['result']['opening_hours']['weekday_text'];
Cache::put('restaurant_hours_' . $restaurant['name'], $hours, now()->addHours(24));
$restaurant['operating_hours'] = $hours;
} else {
$restaurant['operating_hours'] = "N/A";
}
}
}
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $restaurants, 200);
} catch (Exception $ex) {
Log::error('Restaurant Get service failed : ' . $ex->getMessage());
@@ -109,57 +177,100 @@ class RestaurantApiServices
}
}
//
public function DetailRestaurant($customerIamId, $id)
{
try {
$rest = ManageRestaurant::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', 'state_xid')
->where('short_id', $id)
->where('is_active', '1')
->first();
public function DetailRestaurant($customerIamId, $id)
{
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', 'state_xid')->where('short_id', $id)->where('is_active', '1')->first();
if ($rest) {
$rest->image = ListingImageUrl('restaurant_images', $rest->image);
if ($rest) {
$rest->image = ListingImageUrl('restaurant_images', $rest->image);
$isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
->where('restaurant_xid', $rest->id)
->exists();
$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();
->where('manage_restaurants_xid', $rest->id)
->where('is_redeem', "1")
->first();
// $Timeinterval = TimeInterval::where('manage_state_xid', $rest->state_xid)->first();
$restTime = RestaurantTimeInterval::where('manage_restaurants_xid', $rest->id)->first();
$restTime = RestaurantTimeInterval::where('manage_restaurants_xid', $rest->id)->first();
$restTimeHours = $restTime->time_hours;
// $timeIntervalHours = $Timeinterval->time_hours;
$restTimeHours = $restTime->time_hours;
//this below code is updated by hritik on 12-07-2024 by adding restaurant opening hours dynamically from Google
// $rest->operating_hours = getOpeningHoursOfRestaurant($rest->name); //will update later
// Initialize Guzzle HTTP client
$client = new Client();
$googlePlaceApiKey = config('constants.googlePlaces.api_key');
// $greaterTime = max($timeIntervalHours, $restTimeHours);
// Cache key for operating hours
$cacheKey = 'restaurant_hours_' . $rest->name;
if (Cache::has($cacheKey)) {
$rest->operating_hours = Cache::get($cacheKey);
} else {
// Prepare the first request to get the place_id
$placeResponse = $client->get('https://maps.googleapis.com/maps/api/place/findplacefromtext/json', [
'query' => [
'fields' => 'place_id',
'input' => $rest->name,
'inputtype' => 'textquery',
'key' => $googlePlaceApiKey
]
]);
$placeData = json_decode($placeResponse->getBody(), true);
if ($redeem) {
$rest->is_Redeemed = true;
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours($restTimeHours)->toDateTimeString();
if (isset($placeData['candidates'][0]['place_id'])) {
$placeId = $placeData['candidates'][0]['place_id'];
// Prepare the second request to get the operating hours
$detailResponse = $client->get('https://maps.googleapis.com/maps/api/place/details/json', [
'query' => [
'fields' => 'opening_hours',
'place_id' => $placeId,
'key' => $googlePlaceApiKey
]
]);
$detailData = json_decode($detailResponse->getBody(), true);
if (isset($detailData['result']['opening_hours']['weekday_text'])) {
$hours = $detailData['result']['opening_hours']['weekday_text'];
Cache::put($cacheKey, $hours, now()->addHours(24));
$rest->operating_hours = $hours;
} else {
$rest->operating_hours = "N/A";
}
} else {
$rest->is_Redeemed = false;
$rest->redeem_date = null;
$rest->operating_hours = "N/A";
}
}
if (!$rest) {
return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404);
if ($redeem) {
$rest->is_Redeemed = true;
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours($restTimeHours)->toDateTimeString();
} else {
$rest->is_Redeemed = false;
$rest->redeem_date = null;
}
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $rest, 200);
} catch (Exception $e) {
Log::error("Error fetching restaurant data: " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
if (!$rest) {
return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404);
}
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $rest, 200);
} catch (Exception $e) {
Log::error("Error fetching restaurant data: " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
public function removeFromFavourite($customerIamId, $request)
{

View File

@@ -16,7 +16,8 @@
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.9",
"livewire/livewire": "^3.0",
"maatwebsite/excel": "^3.1",
"maatwebsite/excel": "3.1.55",
"phpoffice/phpspreadsheet": "1.29.0",
"stripe/stripe-php": "^15.0",
"tymon/jwt-auth": "^2.1"
},

1063
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -34,5 +34,8 @@ return [
'authentic_success' => 'Authentication Successful',
'confirmed_password' => 'please confirm your passsword',
'redeemed_successfully' => 'Referral code redeemed successfully.',
'save_data_scheduled' => 'Notification Schedule Successfully.',
'save_data_immediate' => 'Notification Sent Successfully.',
];

View File

@@ -57,7 +57,10 @@
<div class="col-md-6">
<div class="form-group">
<label for="company-name" class="label">Upload Image</label>
<input type="file" class="form-control" name="image" accept="image/*">
<input type="file" class="form-control" name="image" accept="image/*"
onchange="previewImage(event)">
<img id="preview" src="#" alt="your image" class="mt-3"
style="display:none;width:20%;" />
</div>
</div>
<div class="col-md-6">
@@ -138,10 +141,12 @@
<div class="col-md-12">
<div class="notification-card">
<h6>Delivery Schedule</h6>
<label for="company-name" class="label">Delivery Schedule</label>
<div class="row">
<div class="col-md-6">
<h6>When should this message start sending?</h6>
<label for="company-name" class="label">When should this message
start sending?</label>
<div class="form-group radio-btn">
<input type="radio" class="form-control" name="schedule_radio1"
id="push_schedule_radi01" value="0">
@@ -182,193 +187,212 @@
</div>
@endsection
@section('section_script')
<script>
$(document).ready(function() {
// Custom validator for checking state checkboxes
$.validator.addMethod('stateRequired', function(value, element) {
let selectedUserType = $('input[name="user_type"]:checked').val();
if (selectedUserType) {
let dropdownId = `dropdown-${selectedUserType}`;
return $(`#${dropdownId} .state-checkbox:checked`).length > 0;
}
return true;
}, 'Please select at least one state.');
<script>
$(document).ready(function() {
// Custom validator for checking state checkboxes
$.validator.addMethod('stateRequired', function(value, element) {
let selectedUserType = $('input[name="user_type"]:checked').val();
if (selectedUserType) {
let dropdownId = `dropdown-${selectedUserType}`;
return $(`#${dropdownId} .state-checkbox:checked`).length > 0;
}
return true;
}, 'Please select at least one state.');
// Validate the form
$('#send_notification_form').validate({
ignore: [],
debug: false,
rules: {
title: {
required: true
},
description: {
required: true
},
image: {
required: true
},
user_type: {
required: true
},
schedule_radio1: {
required: true
},
schedule_date: {
required: function() {
return $('#push_schedule_radi02').is(':checked');
}
},
'states[]': {
stateRequired: true
}
},
messages: {
title: {
required: 'Please enter this field'
},
description: {
required: 'Please enter this field'
},
image: {
required: 'Please upload an image file'
},
user_type: {
required: 'Please select at least one category'
},
schedule_radio1: {
required: 'Please select a delivery schedule'
},
schedule_date: {
required: 'Please select a specific time'
},
'states[]': {
stateRequired: 'Please select at least one state.'
}
},
errorClass: 'error-message',
errorPlacement: function(error, element) {
if (element.attr("name") == "user_type") {
error.insertAfter("#select-ids").addClass('error-message');
} else if (element.attr("name") == "schedule_radio1") {
error.insertAfter("#push_schedule_radi02").addClass('error-message');
} else if (element.attr("name") == "states[]") {
error.insertAfter(`#dropdown-${$('input[name="user_type"]:checked').val()}`).addClass('error-message');
} else {
error.insertAfter(element).addClass('error-message');
}
},
submitHandler: function(form) {
var formData = new FormData(form);
let base_url = url_path;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: base_url + '/insert_notification',
type: 'POST',
data: formData,
beforeSend: function() {
$('#store_notification_btn').html('Please wait...');
$('#store_notification_btn').attr('disabled', true);
// Validate the form
$('#send_notification_form').validate({
ignore: [],
debug: false,
rules: {
title: {
required: true
},
processData: false,
contentType: false,
success: function(result) {
if (result.status_code == 200) {
toastr.success('Data Added Successfully');
setTimeout(function() {
window.location.href = base_url + "/manage-notification";
}, 2000);
} else if (result.status_code == 422) {
// Display validation errors using toastr
$.each(result.errors, function(key, value) {
toastr.error(value);
setTimeout(function() {
window.location.href = base_url + "/manage-notification";
}, 2000);
});
} else {
toastr.error('Something Went Wrong');
setTimeout(function() {
window.location.href = base_url + "/manage-notification";
}, 2000);
description: {
required: true
},
image: {
required: true
},
user_type: {
required: true
},
schedule_radio1: {
required: true
},
schedule_date: {
required: function() {
return $('#push_schedule_radi02').is(':checked');
}
$('#store_notification_btn').attr('disabled', false);
$('#store_notification_btn').text('Submit');
},
});
}
});
// Hide date and time input by default
$('.checkbox-btsss').hide();
// Show/hide date and time input based on radio button selection
$('#push_schedule_radi01').click(function() {
$('.checkbox-btsss').hide();
$('input[name="schedule_date"]').val(''); // Clear date and time input
});
$('#push_schedule_radi02').click(function() {
$('.checkbox-btsss').show();
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
function handleUserTypeChange() {
var dropdowns = [
document.getElementById('dropdown-1'),
document.getElementById('dropdown-2'),
document.getElementById('dropdown-3')
];
dropdowns.forEach(function(dropdown, index) {
if (index + 1 == this.value) {
dropdown.style.display = 'block';
toggleCheckboxes(dropdown, false);
} else {
dropdown.style.display = 'none';
toggleCheckboxes(dropdown, true);
'states[]': {
stateRequired: true
}
},
messages: {
title: {
required: 'Please enter this field'
},
description: {
required: 'Please enter this field'
},
image: {
required: 'Please upload an image file'
},
user_type: {
required: 'Please select at least one category'
},
schedule_radio1: {
required: 'Please select a delivery schedule'
},
schedule_date: {
required: 'Please select a specific time'
},
'states[]': {
stateRequired: 'Please select at least one state.'
}
},
errorClass: 'error-message',
errorPlacement: function(error, element) {
if (element.attr("name") == "user_type") {
error.insertAfter("#select-ids").addClass('error-message');
} else if (element.attr("name") == "schedule_radio1") {
error.insertAfter("#push_schedule_radi02").addClass('error-message');
} else if (element.attr("name") == "states[]") {
error.insertAfter(`#dropdown-${$('input[name="user_type"]:checked').val()}`)
.addClass('error-message');
} else {
error.insertAfter(element).addClass('error-message');
}
},
submitHandler: function(form) {
var formData = new FormData(form);
let base_url = url_path;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: base_url + '/insert_notification',
type: 'POST',
data: formData,
beforeSend: function() {
$('#store_notification_btn').html('Please wait...');
$('#store_notification_btn').attr('disabled', true);
},
processData: false,
contentType: false,
success: function(result) {
if (result.status_code == 200) {
toastr.success(result.message);
setTimeout(function() {
window.location.href = base_url +
"/manage-notification";
}, 2000);
} else if (result.status_code == 422) {
// Display validation errors using toastr
$.each(result.errors, function(key, value) {
toastr.error(value);
setTimeout(function() {
window.location.href = base_url +
"/manage-notification";
}, 2000);
});
} else {
toastr.error('Something Went Wrong');
setTimeout(function() {
window.location.href = base_url +
"/manage-notification";
}, 2000);
}
$('#store_notification_btn').attr('disabled', false);
$('#store_notification_btn').text('Submit');
},
});
}
}, this);
}
});
function toggleCheckboxes(dropdown, disable) {
var checkboxes = dropdown.querySelectorAll('.form-check-input');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].disabled = disable;
// Hide date and time input by default
$('.checkbox-btsss').hide();
// Show/hide date and time input based on radio button selection
$('#push_schedule_radi01').click(function() {
$('.checkbox-btsss').hide();
$('input[name="schedule_date"]').val(''); // Clear date and time input
});
$('#push_schedule_radi02').click(function() {
$('.checkbox-btsss').show();
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
function handleUserTypeChange() {
var dropdowns = [
document.getElementById('dropdown-1'),
document.getElementById('dropdown-2'),
document.getElementById('dropdown-3')
];
dropdowns.forEach(function(dropdown, index) {
if (index + 1 == this.value) {
dropdown.style.display = 'block';
toggleCheckboxes(dropdown, false);
} else {
dropdown.style.display = 'none';
toggleCheckboxes(dropdown, true);
}
}, this);
}
function toggleCheckboxes(dropdown, disable) {
var checkboxes = dropdown.querySelectorAll('.form-check-input');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].disabled = disable;
}
}
var userTypeRadios = document.getElementsByName('user_type');
for (var i = 0; i < userTypeRadios.length; i++) {
userTypeRadios[i].addEventListener('change', handleUserTypeChange);
}
var checkedRadio = document.querySelector('input[name="user_type"]:checked');
if (checkedRadio) {
handleUserTypeChange.call(checkedRadio);
}
function handleSelectAllChange() {
var dropdown = this.closest('div[id^="dropdown-"]');
var checkboxes = dropdown.querySelectorAll('.state-checkbox');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = this.checked;
}
}
var selectAllCheckboxes = document.querySelectorAll('.select-all-checkbox');
for (var i = 0; i < selectAllCheckboxes.length; i++) {
selectAllCheckboxes[i].addEventListener('change', handleSelectAllChange);
}
});
</script>
<script>
function previewImage(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function() {
var preview = document.getElementById('preview');
preview.src = reader.result;
preview.style.display = 'block';
};
if (input.files && input.files[0]) {
reader.readAsDataURL(input.files[0]);
}
}
var userTypeRadios = document.getElementsByName('user_type');
for (var i = 0; i < userTypeRadios.length; i++) {
userTypeRadios[i].addEventListener('change', handleUserTypeChange);
}
var checkedRadio = document.querySelector('input[name="user_type"]:checked');
if (checkedRadio) {
handleUserTypeChange.call(checkedRadio);
}
function handleSelectAllChange() {
var dropdown = this.closest('div[id^="dropdown-"]');
var checkboxes = dropdown.querySelectorAll('.state-checkbox');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = this.checked;
}
}
var selectAllCheckboxes = document.querySelectorAll('.select-all-checkbox');
for (var i = 0; i < selectAllCheckboxes.length; i++) {
selectAllCheckboxes[i].addEventListener('change', handleSelectAllChange);
}
});
</script>
</script>
@endsection

View File

@@ -1,83 +1,91 @@
@extends('Admin.layouts.master')
@section('content')
@php
$currentPage = 'manage-notification';
@endphp
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-4 left">
<a class="d-flex align-items-center justify-content-center pl-2"
href="{{ route('manage.notification')}}">
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg')}}">
<h6 class="card-title p-0">View Details</h6>
</a>
</div>
@php
$currentPage = 'manage-notification';
@endphp
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-4 left">
<a class="d-flex align-items-center justify-content-center pl-2"
href="{{ route('manage.notification') }}">
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg') }}">
<h6 class="card-title p-0">View Details</h6>
</a>
</div>
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn p-0">
<div class="view-details">
<div class="simple-tab">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
aria-labelledby="home-tab" tabindex="0">
<div class="row">
<div class="col-md-6 mb-10 tabs23">
<table>
<tr class="title">
<td>Notification content :</td>
<td>Created Date :</td>
</tr>
<tr class="w-100">
<td>{{ $notification->description }}</td>
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}</td>
</tr>
</table>
</div>
<div class="col-md-6 mb-10">
<table>
<tr class="title">
<td>Recipients :</td>
{{-- <td>Last Modified Date :</td> --}}
</tr>
<tr class="w-100">
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn p-0">
<div class="view-details">
<div class="simple-tab">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
aria-labelledby="home-tab" tabindex="0">
<div class="row">
<div class="col-md-6 mb-10 tabs23">
<table>
<tr class="title">
<td>Message :</td>
<td>Description :</td>
<td>Created Date :</td>
</tr>
<tr class="w-100">
<td>{{ $notification->type }}</td>
<td>{{ $notification->description }}</td>
<td>@if($notification->notification->principal_type_xid == '3')
Customer
@else
Resturant
@endif
</td>
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}
</td>
</tr>
</tr>
</table>
</div>
</table>
</div>
<div class="col-md-6 mb-10">
<table>
<tr class="title">
<td>Recipients :</td>
<td>Image :</td>
{{-- <td>Last Modified Date :</td> --}}
</tr>
<tr class="w-100">
<td>
@if ($notification->notification->principal_type_xid == '3')
Customer
@else
Resturant
@endif
</td>
<td>
<img src="{{ $notification->image }}" alt="Notification Image"
style="max-width: 100px; max-height: 100px;">
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -17,7 +17,7 @@ $currentPage = 'manage-reports';
</div>
</div>
</div>
<form id="reportForm" action="{{ route('export.reports') }}" method="POST">
<form id="reportForm" action="{{route('reports.export')}}" method="POST">
@csrf
<div class="row widget-content widget-content-area br-8 position-btn m-auto py-3" style="overflow: auto;">
<div class="col-6">

View File

@@ -8,9 +8,9 @@
<body>
<h1>{{ $reportType }} Report</h1>
@if ($data->isEmpty())
<!-- @if ($data->isEmpty())
<p>No data available</p>
@else
@else -->
@if ($reportType === 'Total Subscribed')
<table>

View File

@@ -0,0 +1,201 @@
<!DOCTYPE html>
<html>
<head>
<title>Report</title>
</head>
<body>
<h1>{{ $reportType }} Report</h1>
<!-- @if ($data->isEmpty())
<p>No data available</p>
@else -->
@if ($reportType === 'Total Subscribed')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>Subscription ID</th>
<th>User Name</th>
<th>State</th>
<th>Subscription Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $subscription)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $subscription->id }}</td>
<td>{{ $subscription->iamPrincipal->first_name ?? 'N/A' }} {{ $subscription->iamPrincipal->last_name ?? 'N/A' }} </td>
<td>{{ $subscription->iamPrincipal->state->name ?? 'N/A' }}</td>
<td>{{\Carbon\Carbon::parse($subscription->created_at)->format('m-d-Y H:i')}}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Total Users')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>Customer ID</th>
<th>Customer Name</th>
<th>State</th>
<th>Customer Join Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $user)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $user->id }}</td>
<td>{{ $user->first_name }} {{ $user->last_name }}</td>
<td>{{ $user->state->name }}</td>
<td>{{ \Carbon\Carbon::parse($user->created_at)->format('m-d-Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Redemptions')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>Redemption ID</th>
<th>Restaurant Name</th>
<th>Customer Name</th>
<th>State</th>
<th>Redemption Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $redemption)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $redemption->id }}</td>
<td>{{ $redemption->restaurant->name }}</td>
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
<td>{{ $redemption->customer->state->name }}</td>
<td>{{\Carbon\Carbon::parse($redemption->created_at)->format('m-d-Y H:i')}} </td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Redemptions for Specific Restaurants')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>Redemption ID</th>
<th>Restaurant Name</th>
<th>Customer Name</th>
<th>State</th>
<th>Redemption Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $redemption)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $redemption->id }}</td>
<td>{{ $redemption->restaurant->name }}</td>
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
<td>{{ $redemption->customer->state->name }}</td>
<td>{{\Carbon\Carbon::parse($redemption->created_at)->format('m-d-Y H:i')}} </td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Subscriptions Cancelled')
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>State</th>
<th>Subscription Status</th>
<th>Subscription Cancel Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $item)
<tr>
<td>{{ $item->iamPrincipal->first_name }} {{ $item->iamPrincipal->last_name }}</td>
<td>{{ $item->iamPrincipal->email_address }}</td>
<td>{{ $item->iamPrincipal->state->name }}</td>
<td>{{ $item->subscription_status }}</td>
<td>{{ \Carbon\Carbon::parse($item->cancelled_at)->format('m-d-Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Referrals Made')
<table>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>State</th>
<th>Referred Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $referral)
<tr>
<td>{{ $referral->id }}</td>
<td>{{ $referral->referredUser->first_name }} {{ $referral->referredUser->last_name }}</td>
<td>{{ $referral->referredUser->email_address }}</td>
<td>{{ $referral->referredUser->phone_number}}</td>
<td>{{ $referral->referredUser->state->name }}</td>
<td> {{ \Carbon\Carbon::parse($referral->referred_date_time)->format('m-d-Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Referees Joined')
<table>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Phone number</th>
<th>State</th>
<th>Referred Date Time</th>
</tr>
</thead>
<tbody>
@foreach($data as $referees)
<tr>
<td>{{$referees->id }}</td>
<td>{{ $referees->refeersUser->first_name }} {{ $referees->refeersUser->last_name }}</td>
<td>{{ $referees->refeersUser->email_address }}</td>
<td>{{ $referees->refeersUser->phone_number}}</td>
<td>{{ $referees->refeersUser->state->name }}</td>
<td> {{ \Carbon\Carbon::parse($referees->referred_date_time)->format('m-d-Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
<!-- @endif -->
</body>
</html>

View File

@@ -63,6 +63,7 @@ Route::middleware(['customerApiBasicAuth'])->group(function () {
Route::post('/v1/reset-user-password', [CustomerControllerApi::class, 'resetUserPassword']);
Route::post('/v1/customer-logout', [CustomerControllerApi::class, 'customerLogout']);
Route::post('/v1/delete_account', [CustomerControllerApi::class, 'destroyAccount']);
Route::get('/v1/check_subscription', [CustomerControllerApi::class, 'CheckSubscription']);
//*******************************************************Restaurant********************************************************
Route::get('/v1/detail-of-restaurant/{id}', [RestaurantControllerApi::class, 'DetailRestaurant']);
@@ -93,6 +94,8 @@ Route::middleware(['customerApiBasicAuth'])->group(function () {
//*******************************************************Rules ********************************************************
Route::get('/v1/voucher-rules', [RulesControllerAPI::class, 'getVoucherRules']);
});

View File

@@ -176,7 +176,8 @@ Route::group(['middleware' => ['checkStatus']], function () {
//*******************************************************manage reports********************************************************
Route::get('/manage-reports', [ManageReportsController::class, 'index'])->name('manage.reports');
Route::post('/export-reports', [ManageReportsController::class, 'exportReports'])->name('export.reports');
// Route::post('/export-reports', [ManageReportsController::class, 'exportReports'])->name('export.reports');
Route::post('/export-reports', [ManageReportsController::class, 'exportReport'])->name('reports.export');
//*******************************************************manage feedback********************************************************
Route::get('/manage-feedback', [ManageFeedbackController::class, 'index'])->name('manage.feedback');