⚝
One Hat Cyber Team
⚝
Your IP:
172.22.0.1
Server IP:
151.80.20.34
Server:
Linux 794f04d97d5e 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
Server Software:
Apache/2.4.62 (Debian)
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
html
/
app
/
Models
/
Edit File: Proposal.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Proposal extends Model { protected $fillable = [ 'proposal_id', 'customer_id', 'issue_date', 'status', 'category_id', 'is_convert', 'converted_invoice_id', 'created_by', ]; public static $statues = [ 'Draft', 'Open', 'Accepted', 'Declined', 'Close', ]; public function tax() { return $this->hasOne('App\Models\Tax', 'id', 'tax_id'); } public function items() { return $this->hasMany('App\Models\ProposalProduct', 'proposal_id', 'id'); } public function customer() { return $this->hasOne('App\Models\Customer', 'id', 'customer_id'); } public function getSubTotal() { $subTotal = 0; foreach($this->items as $product) { $subTotal += ($product->price * $product->quantity); } return $subTotal; } // public function getTotalTax() // { // $totalTax = 0; // foreach($this->items as $product) // { // $taxes = Utility::totalTaxRate($product->tax); // $totalTax += ($taxes / 100) * ($product->price * $product->quantity - $product->discount) ; // } // return $totalTax; // } public function getTotalTax() { $taxData = Utility::getTaxData(); $totalTax = 0; foreach($this->items as $product) { // $taxes = Utility::totalTaxRate($product->tax); $taxArr = explode(',', $product->tax); $taxes = 0; foreach ($taxArr as $tax) { // $tax = TaxRate::find($tax); $taxes += !empty($taxData[$tax]['rate']) ? $taxData[$tax]['rate'] : 0; } $totalTax += ($taxes / 100) * ($product->price * $product->quantity); } return $totalTax; } public function getTotalDiscount() { $totalDiscount = 0; foreach($this->items as $product) { $totalDiscount += $product->discount; } return $totalDiscount; } public function getTotal() { return ($this->getSubTotal() -$this->getTotalDiscount()) + $this->getTotalTax(); } public function getDue() { $due = 0; foreach($this->payments as $payment) { $due += $payment->amount; } return ($this->getTotal() - $due) - $this->invoiceTotalCreditNote(); } public static function change_status($proposal_id, $status) { $proposal = Proposal::find($proposal_id); $proposal->status = $status; $proposal->update(); } public function category() { return $this->hasOne('App\Models\ProductServiceCategory', 'id', 'category_id'); } public function taxes() { return $this->hasOne('App\Models\Tax', 'id', 'tax'); } }
Simpan