osb/app/Models/Checkout.php

43 lines
679 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Checkout extends Model
{
protected $table = 'ab_checkout';
public $timestamps = FALSE;
public function payments()
{
return $this->hasMany(Payment::class);
}
2020-07-27 04:49:59 +00:00
/** SCOPES **/
/**
* Search for a record
*
* @param $query
* @param string $term
* @return
*/
public function scopeActive($query)
{
return $query->where('active',TRUE);
}
/** FUNCTIONS **/
public function fee(float $amt,int $items=1): float
{
if (! $this->fee_passon OR ! $items)
return 0;
$fee = $amt+$this->fee_fixed/$items;
$fee /= (1-$this->fee_variable);
return round($fee-$amt,2);
}
}