mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
class TransactionDetail extends AbstractModel
|
|
{
|
|
protected $table = 'transaction_detail';
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function transaction(): BelongsTo
|
|
{
|
|
return $this->BelongsTo( Transaction::class, 'transaction_id', 'id');
|
|
}
|
|
|
|
public function convert_original_price()
|
|
{
|
|
if($this->transaction()->first()->booking()->first()->fix_currency_id !== 1) {
|
|
$currency_rate = $this->transaction()->first()->currency()->first()->rates()->where('payment_method_type', $this->transaction()->first()->payment_method)->first();
|
|
return number_format($this->price / $currency_rate->selling, 2);
|
|
}
|
|
return $this->price;
|
|
}
|
|
|
|
public function convert_original_amount()
|
|
{
|
|
if($this->transaction()->first()->booking()->first()->fix_currency_id !== 1) {
|
|
$currency_rate = $this->transaction()->first()->currency()->first()->rates()->where('payment_method_type', $this->transaction()->first()->payment_method)->first();
|
|
return number_format($this->amount / $currency_rate->selling, 2);
|
|
}
|
|
return $this->amount;
|
|
}
|
|
}
|