Added and applied updatePricing function
Added and applied updatePricing function
This commit is contained in:
parent
9204a05654
commit
18c73aca95
|
@ -114,18 +114,7 @@ class DomainsController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
DB::table('pricings')
|
$pricing->updatePricing($domain->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
->where('service_id', $domain->id)
|
|
||||||
->update([
|
|
||||||
'service_type' => 4,
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
'active' => (isset($request->is_active)) ? 1 : 0
|
|
||||||
]);
|
|
||||||
|
|
||||||
$domain->update([
|
$domain->update([
|
||||||
'domain' => $request->domain,
|
'domain' => $request->domain,
|
||||||
|
|
|
@ -50,16 +50,7 @@ class MiscController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
Pricing::create([
|
$pricing->insertPricing(5, $ms_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
'service_id' => $ms_id,
|
|
||||||
'service_type' => 5,
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Misc::create([
|
Misc::create([
|
||||||
'id' => $ms_id,
|
'id' => $ms_id,
|
||||||
|
@ -104,17 +95,7 @@ class MiscController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
DB::table('pricings')
|
$pricing->updatePricing($misc->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
->where('service_id', $misc->id)
|
|
||||||
->update([
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
'active' => (isset($request->is_active)) ? 1 : 0
|
|
||||||
]);
|
|
||||||
|
|
||||||
Cache::forget('services_count');//Main page services_count cache
|
Cache::forget('services_count');//Main page services_count cache
|
||||||
Cache::forget('due_soon');//Main page due_soon cache
|
Cache::forget('due_soon');//Main page due_soon cache
|
||||||
|
|
|
@ -194,16 +194,7 @@ class ResellerController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
DB::table('pricings')
|
$pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
->where('service_id', $request->id)
|
|
||||||
->update([
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Labels::deleteLabelsAssignedTo($request->id);
|
Labels::deleteLabelsAssignedTo($request->id);
|
||||||
|
|
||||||
|
|
|
@ -244,18 +244,7 @@ class ServerController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
DB::table('pricings')
|
$pricing->updatePricing($server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
->where('service_id', $server_id)
|
|
||||||
->update([
|
|
||||||
'service_type' => 1,
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
'active' => (isset($request->is_active)) ? 1 : 0
|
|
||||||
]);
|
|
||||||
|
|
||||||
Labels::deleteLabelsAssignedTo($server_id);
|
Labels::deleteLabelsAssignedTo($server_id);
|
||||||
|
|
||||||
|
|
|
@ -193,16 +193,7 @@ class SharedController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
DB::table('pricings')
|
$pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
->where('service_id', $request->id)
|
|
||||||
->update([
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'price' => $request->price,
|
|
||||||
'term' => $request->payment_term,
|
|
||||||
'as_usd' => $as_usd,
|
|
||||||
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
|
|
||||||
'next_due_date' => $request->next_due_date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Labels::deleteLabelsAssignedTo($request->id);
|
Labels::deleteLabelsAssignedTo($request->id);
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,26 @@ class Pricing extends Model
|
||||||
DB::table('pricings')->where('service_id', '=', $id)->delete();
|
DB::table('pricings')->where('service_id', '=', $id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertPricing(int $type, string $server_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, float $as_usd, string $next_due_date, int $is_active = 1)
|
||||||
{
|
{
|
||||||
return self::create([
|
return self::create([
|
||||||
'service_type' => $type,
|
'service_type' => $type,
|
||||||
'service_id' => $server_id,
|
'service_id' => $service_id,
|
||||||
|
'currency' => $currency,
|
||||||
|
'price' => $price,
|
||||||
|
'term' => $term,
|
||||||
|
'as_usd' => $as_usd,
|
||||||
|
'usd_per_month' => $this->costAsPerMonth($as_usd, $term),
|
||||||
|
'next_due_date' => $next_due_date,
|
||||||
|
'active' => ($is_active) ? 1 : 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatePricing(string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1)
|
||||||
|
{
|
||||||
|
return DB::table('pricings')
|
||||||
|
->where('service_id', $service_id)
|
||||||
|
->update([
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
'term' => $term,
|
'term' => $term,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user