Updated pricing model insertPricing() func

Updated pricing model insertPricing() function
Move as_usd parameter into the function
Updated is_active check as it is an int anyway
This commit is contained in:
cp6 2022-08-30 23:37:05 +10:00
parent 01e2613d90
commit d1eb588b11
8 changed files with 10 additions and 20 deletions

View File

@ -307,10 +307,7 @@ class ApiController extends Controller
$server_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
if (!is_null($request->ip1)) {
IPs::insertIP($server_id, $request->ip1);

View File

@ -43,8 +43,7 @@ class DomainsController extends Controller
$domain_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(4, $domain_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(4, $domain_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Domains::create([
'id' => $domain_id,

View File

@ -41,8 +41,7 @@ class MiscController extends Controller
$misc_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(5, $misc_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(5, $misc_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Misc::create([
'id' => $misc_id,

View File

@ -57,8 +57,7 @@ class ResellerController extends Controller
$reseller_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(3, $reseller_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(3, $reseller_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
if (!is_null($request->dedicated_ip)) {
IPs::insertIP($reseller_id, $request->dedicated_ip);

View File

@ -47,8 +47,7 @@ class SeedBoxesController extends Controller
$seedbox_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(6, $seedbox_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(6, $seedbox_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox_id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox_id);

View File

@ -75,10 +75,7 @@ class ServerController extends Controller
$server_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
if (!is_null($request->ip1)) {
IPs::insertIP($server_id, $request->ip1);

View File

@ -52,8 +52,7 @@ class SharedController extends Controller
$shared_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(2, $shared_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$pricing->insertPricing(2, $shared_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($shared_id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $shared_id);

View File

@ -103,8 +103,9 @@ class Pricing extends Model
DB::table('pricings')->where('service_id', '=', $id)->delete();
}
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1)
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1)
{
$as_usd = $this->convertToUSD($price, $currency);
return self::create([
'service_type' => $type,
'service_id' => $service_id,
@ -114,7 +115,7 @@ class Pricing extends Model
'as_usd' => $as_usd,
'usd_per_month' => $this->costAsPerMonth($as_usd, $term),
'next_due_date' => $next_due_date,
'active' => ($is_active) ? 1 : 0
'active' => $is_active
]);
}