Added insertPricing & allPricing function
Added insertPricing & allPricing function
This commit is contained in:
parent
3948dd50db
commit
9204a05654
|
@ -63,16 +63,7 @@ class DomainsController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
Pricing::create([
|
$pricing->insertPricing(4, $domain_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
'service_id' => $domain_id,
|
|
||||||
'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,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Domains::create([
|
Domains::create([
|
||||||
'id' => $domain_id,
|
'id' => $domain_id,
|
||||||
|
|
|
@ -66,16 +66,7 @@ class ResellerController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
Pricing::create([
|
$pricing->insertPricing(3, $reseller_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
'service_id' => $reseller_id,
|
|
||||||
'service_type' => 3,
|
|
||||||
'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,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!is_null($request->dedicated_ip)) {
|
if (!is_null($request->dedicated_ip)) {
|
||||||
IPs::insertIP($reseller_id, $request->dedicated_ip);
|
IPs::insertIP($reseller_id, $request->dedicated_ip);
|
||||||
|
|
|
@ -110,16 +110,7 @@ class ServerController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
Pricing::create([
|
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
'service_id' => $server_id,
|
|
||||||
'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,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!is_null($request->ip1)) {
|
if (!is_null($request->ip1)) {
|
||||||
IPs::insertIP($server_id, $request->ip1);
|
IPs::insertIP($server_id, $request->ip1);
|
||||||
|
@ -204,7 +195,7 @@ class ServerController extends Controller
|
||||||
->where('s.id', '=', $server->id)
|
->where('s.id', '=', $server->id)
|
||||||
->get(['s.*', 'p.*']);
|
->get(['s.*', 'p.*']);
|
||||||
|
|
||||||
return view('servers.edit', compact(['server','ip_addresses']));
|
return view('servers.edit', compact(['server', 'ip_addresses']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Server $server)
|
public function update(Request $request, Server $server)
|
||||||
|
|
|
@ -64,16 +64,7 @@ class SharedController extends Controller
|
||||||
|
|
||||||
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
|
||||||
|
|
||||||
Pricing::create([
|
$pricing->insertPricing(2, $shared_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
|
||||||
'service_id' => $shared_id,
|
|
||||||
'service_type' => 2,
|
|
||||||
'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($shared_id);
|
Labels::deleteLabelsAssignedTo($shared_id);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
class Pricing extends Model
|
class Pricing extends Model
|
||||||
{
|
{
|
||||||
|
@ -75,4 +77,27 @@ 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)
|
||||||
|
{
|
||||||
|
return self::create([
|
||||||
|
'service_type' => $type,
|
||||||
|
'service_id' => $server_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 static function allPricing()
|
||||||
|
{
|
||||||
|
return Cache::remember('all_pricing', now()->addWeek(1), function () {
|
||||||
|
return DB::table('pricings')
|
||||||
|
->get();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user