File "Transaction.php"

Full Path: /home/isoftco/public_html/hrm/app/Models/Transaction.php
File size: 481 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Transaction extends Model
{


    protected $table = "transactions";

    protected $guarded = ["id"];

    public static function convertAmount($amount, $fromCurrency)
    {
        $currencyConversion = file_get_contents("currency.json");;

        $jsonData = json_decode($currencyConversion);

        $value = round(($amount / ($jsonData->rates->$fromCurrency)), 0);

        return $value;
    }
}