changes
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Exports\CustomerExportSelected;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Barryvdh\DomPDF\PDF as DomPDFPDF;
|
||||
@@ -34,21 +35,31 @@ class ManageCustomerController extends Controller
|
||||
Created at : 28 May 2024
|
||||
Use : To Get User Page.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
// Eager load the state relationship for all customers
|
||||
$customers = IamPrincipal::where('principal_type_xid', 3)
|
||||
->with('state')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$customers = IamPrincipal::with(['isSubscribed', 'state'])
|
||||
->where('principal_type_xid', 3)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
return view('Admin.pages.manage_users.manage_customer.customer', compact('customers'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("Manage Voucher Page Not Load " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$customer->is_subscribed = $customer->isSubscribed->contains(function ($subscription) use ($formattedDateTime) {
|
||||
return $subscription->subscription_status == 'active' && $subscription->next_payment_date >= $formattedDateTime;
|
||||
});
|
||||
}
|
||||
|
||||
return view('Admin.pages.manage_users.manage_customer.customer', compact('customers'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("Manage Voucher Page Not Load " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
@@ -56,13 +67,14 @@ class ManageCustomerController extends Controller
|
||||
*/
|
||||
public function view_customer($id)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
$customers_data = IamPrincipal::with('state', 'contactMessages')->findOrFail($id);
|
||||
$customers_data = IamPrincipal::with('state', 'contactMessages','isSubscribed')->findOrFail($id);
|
||||
if ($customers_data->contactMessages->isEmpty()) {
|
||||
Log::info('No contact messages found for customer with ID: ' . $id);
|
||||
}
|
||||
if ($customers_data->isSubscribed->isEmpty()) {
|
||||
Log::info('No payment history found for customer with ID: ' . $id);
|
||||
}
|
||||
// return $customers_data;
|
||||
return view('Admin.pages.manage_users.manage_customer.view_customer_details', compact('customers_data'));
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user