<?php

namespace App\Http\Helpers;

use App\Models\MuhandisinsProfit;

class ProfitCalculator {
    public static function calculate($amount){
        return $amount * (1 - MuhandisinsProfit::
            where('from', '<=', $amount)
                ->where('to', '>=', $amount)
                ->get()?->first()?->profit
                ?? last(MuhandisinsProfit::all()->toArray()));
    }
}
