[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: InstallmentOrder.php
<?php namespace App\Models; use App\User; use Illuminate\Database\Eloquent\Model; class InstallmentOrder extends Model { protected $table = 'installment_orders'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } public function installment() { return $this->belongsTo(Installment::class, 'installment_id', 'id'); } public function selectedInstallment() { return $this->hasOne(SelectedInstallment::class, 'installment_order_id', 'id'); } public function webinar() { return $this->belongsTo(Webinar::class, 'webinar_id', 'id'); } public function product() { return $this->belongsTo(Product::class, 'product_id', 'id'); } public function bundle() { return $this->belongsTo(Bundle::class, 'bundle_id', 'id'); } public function subscribe() { return $this->belongsTo(Subscribe::class, 'subscribe_id', 'id'); } public function registrationPackage() { return $this->belongsTo(RegistrationPackage::class, 'registration_package_id', 'id'); } public function payments() { return $this->hasMany(InstallmentOrderPayment::class, 'installment_order_id', 'id'); } public function attachments() { return $this->hasMany(InstallmentOrderAttachment::class, 'installment_order_id', 'id'); } /******** * Helpers * */ public function getItem() { $item = null; if (!empty($this->webinar_id)) { $item = $this->webinar; } else if (!empty($this->bundle_id)) { $item = $this->bundle; } else if (!empty($this->product_id)) { $item = $this->product; } else if (!empty($this->subscribe_id)) { $item = $this->subscribe; } else if (!empty($this->registration_package_id)) { $item = $this->registrationPackage; } return $item; } public function getItemType() { $type = null; if (!empty($this->webinar_id)) { $type = 'course'; } else if (!empty($this->bundle_id)) { $type = "bundle"; } else if (!empty($this->product_id)) { $type = "product"; } else if (!empty($this->subscribe_id)) { $type = "subscribe"; } else if (!empty($this->registration_package_id)) { $type = "registrationPackage"; } return $type; } public function getItemPrice() { return $this->attributes['item_price']; } public function isCompleted() { $result = false; if ($this->status == "open") { $installment = $this->selectedInstallment; $installmentSteps = $installment->steps; $paid = true; foreach ($installmentSteps as $step) { if ($paid) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $paid = false; } } } $result = $paid; } return $result; } public function checkOrderHasOverdue() { $result = false; $time = time(); if ($this->status == 'open') { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $result = true; } } } } return $result; } public function getOrderOverdueCountAndAmount() { $count = 0; $amount = 0; $time = time(); $itemPrice = $this->getItemPrice(); if ($this->status == 'open' and !empty($itemPrice)) { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $count += 1; $amount += $step->getPrice($itemPrice); } } } } return [ 'count' => $count, 'amount' => $amount, ]; } public function overdueDaysPast() { $result = 0; $time = time(); if ($this->status == 'open') { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $daysPast = ($time - $dueAt) / (86400); $result = $daysPast > 0 ? $daysPast : 0; } } } } return $result; } public function getCompletePrice($itemPrice = null) { if (empty($itemPrice)) { $itemPrice = $this->getItemPrice(); } $amount = 0; $installment = $this->selectedInstallment; if (!empty($installment)) { $amount = $installment->getUpfront($itemPrice); foreach ($installment->steps as $step) { $amount += $step->getPrice($itemPrice); } } return $amount; } }
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.86 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