Updated Reseller model to use relationships

Updated Reseller model to use relationships
Added caching for Reseller
This commit is contained in:
cp6 2022-07-19 15:55:10 +10:00
parent dbc54c44d1
commit eb31701076
6 changed files with 151 additions and 158 deletions

View File

@ -18,16 +18,13 @@ class ResellerController extends Controller
{ {
public function index() public function index()
{ {
$resellers = Reseller::resellerDataIndexPage(); $resellers = Reseller::allResellerHosting();
return view('reseller.index', compact(['resellers'])); return view('reseller.index', compact(['resellers']));
} }
public function create() public function create()
{ {
$Providers = Providers::allProviders(); return view('reseller.create');
$Locations = Locations::allLocations();
return view('reseller.create', compact(['Providers', 'Locations']));
} }
public function store(Request $request) public function store(Request $request)
@ -60,9 +57,7 @@ class ResellerController extends Controller
$reseller_id = Str::random(8); $reseller_id = Str::random(8);
$pricing = new Pricing(); $pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $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, $as_usd, $request->next_due_date);
if (!is_null($request->dedicated_ip)) { if (!is_null($request->dedicated_ip)) {
@ -91,32 +86,23 @@ class ResellerController extends Controller
'db_limit' => $request->db 'db_limit' => $request->db
]); ]);
Cache::forget("all_reseller");
Home::homePageCacheForget(); Home::homePageCacheForget();
return redirect()->route('reseller.index') return redirect()->route('reseller.index')
->with('success', 'Reseller hosting created Successfully.'); ->with('success', 'Reseller hosting created Successfully.');
} }
public function show(Reseller $reseller) public function show(Reseller $reseller)
{ {
$reseller_extras = Reseller::resellerDataShowPage($reseller->id); $reseller = Reseller::resellerHosting($reseller->id)[0];
return view('reseller.show', compact(['reseller']));
$labels = Labels::labelsForService($reseller->id);
$ip_address = IPs::ipsForServer($reseller->id);
return view('reseller.show', compact(['reseller', 'reseller_extras', 'labels', 'ip_address']));
} }
public function edit(Reseller $reseller) public function edit(Reseller $reseller)
{ {
$labels = Labels::labelsForService($reseller->id); $reseller = Reseller::resellerHosting($reseller->id)[0];
return view('reseller.edit', compact(['reseller']));
$ip_address = IPs::ipsForServer($reseller->id);
$reseller = Reseller::resellerDataEditPage($reseller->id);
return view('reseller.edit', compact(['reseller', 'ip_address', 'labels']));
} }
public function update(Request $request, Reseller $reseller) public function update(Request $request, Reseller $reseller)
@ -164,13 +150,10 @@ class ResellerController extends Controller
]); ]);
$pricing = new Pricing(); $pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date); $pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($request->id); Labels::deleteLabelsAssignedTo($request->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $request->id); Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $request->id);
IPs::deleteIPsAssignedTo($request->id); IPs::deleteIPsAssignedTo($request->id);
@ -179,6 +162,7 @@ class ResellerController extends Controller
IPs::insertIP($request->id, $request->dedicated_ip); IPs::insertIP($request->id, $request->dedicated_ip);
} }
Cache::forget("reseller_hosting.{$request->id}");
Cache::forget("labels_for_service.{$request->id}"); Cache::forget("labels_for_service.{$request->id}");
Home::homePageCacheForget(); Home::homePageCacheForget();
@ -189,18 +173,19 @@ class ResellerController extends Controller
public function destroy(Reseller $reseller) public function destroy(Reseller $reseller)
{ {
$id = $reseller->id; $reseller_id = $reseller->id;
$items = Reseller::find($id); $items = Reseller::find($reseller_id);
$items->delete(); $items->delete();
$p = new Pricing(); $p = new Pricing();
$p->deletePricing($id); $p->deletePricing($reseller_id);
Labels::deleteLabelsAssignedTo($id); Labels::deleteLabelsAssignedTo($reseller_id);
IPs::deleteIPsAssignedTo($id); IPs::deleteIPsAssignedTo($reseller_id);
Cache::forget("all_reseller");
Cache::forget("reseller_hosting.$reseller_id");
Home::homePageCacheForget(); Home::homePageCacheForget();
return redirect()->route('reseller.index') return redirect()->route('reseller.index')

View File

@ -17,32 +17,44 @@ class Reseller extends Model
public $incrementing = false; public $incrementing = false;
public static function resellerDataIndexPage() public static function allResellerHosting()
{ {//All reseller hosting and relationships (no using joins)
return DB::table('reseller_hosting as s') return Cache::remember("all_reseller", now()->addMonth(1), function () {
->join('providers as p', 's.provider_id', '=', 'p.id') return Reseller::with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
->join('locations as l', 's.location_id', '=', 'l.id') });
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
} }
public static function resellerDataShowPage(string $reseller_id) public static function resellerHosting(string $shared_id)
{ {//Single reseller hosting and relationships (no using joins)
return DB::table('reseller_hosting as s') return Cache::remember("reseller_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) {
->join('pricings as pr', 's.id', '=', 'pr.service_id') return Reseller::where('id', $shared_id)
->join('providers as p', 's.provider_id', '=', 'p.id') ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
->join('locations as l', 's.location_id', '=', 'l.id') });
->where('s.id', '=', $reseller_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
} }
public static function resellerDataEditPage(string $reseller_id) public function ips()
{ {
return DB::table('reseller_hosting as s') return $this->hasMany(IPs::class, 'service_id', 'id');
->join('pricings as p', 's.id', '=', 'p.service_id') }
->where('s.id', '=', $reseller_id)
->get(['s.*', 'p.*']);
public function location()
{
return $this->hasOne(Locations::class, 'id', 'location_id');
}
public function provider()
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function price()
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels()
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
} }
} }

View File

@ -1,7 +1,7 @@
@section('title') {{$reseller[0]->main_domain}} {{'edit'}} @endsection @section('title') {{$reseller->main_domain}} {{'edit'}} @endsection
<x-app-layout> <x-app-layout>
<x-slot name="header"> <x-slot name="header">
Edit {{ $reseller[0]->main_domain }} Edit {{ $reseller->main_domain }}
</x-slot> </x-slot>
<div class="container"> <div class="container">
@ -12,7 +12,7 @@
Back to reseller hosting Back to reseller hosting
</a> </a>
<x-auth-validation-errors></x-auth-validation-errors> <x-auth-validation-errors></x-auth-validation-errors>
<form action="{{ route('reseller.update', $reseller[0]->service_id) }}" method="POST"> <form action="{{ route('reseller.update', $reseller->id) }}" method="POST">
@csrf @csrf
@method('PUT') @method('PUT')
<div class="row mt-3"> <div class="row mt-3">
@ -21,58 +21,58 @@
<div class="input-group-prepend"><span class="input-group-text">Domain</span></div> <div class="input-group-prepend"><span class="input-group-text">Domain</span></div>
<input type="text" <input type="text"
class="form-control" class="form-control"
name="domain" value="{{$reseller[0]->main_domain}}"> name="domain" value="{{$reseller->main_domain}}">
@error('name') <span class="text-red-500">{{ $message }} @error('name') <span class="text-red-500">{{ $message }}
</span>@enderror </span>@enderror
</div> </div>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<input type="hidden" name="id" value="{{$reseller[0]->service_id}}"> <input type="hidden" name="id" value="{{$reseller->id}}">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div> <div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" name="reseller_type"> <select class="form-control" name="reseller_type">
<option <option
value="ApisCP" {{ ($reseller[0]->reseller_type === 'ApisCP') ? 'selected' : '' }}> value="ApisCP" {{ ($reseller->reseller_type === 'ApisCP') ? 'selected' : '' }}>
ApisCP ApisCP
</option> </option>
<option <option
value="Centos" {{ ($reseller[0]->reseller_type === 'Centos') ? 'selected' : '' }}> value="Centos" {{ ($reseller->reseller_type === 'Centos') ? 'selected' : '' }}>
Centos Centos
</option> </option>
<option <option
value="cPanel" {{ ($reseller[0]->reseller_type === 'cPanel') ? 'selected' : '' }}> value="cPanel" {{ ($reseller->reseller_type === 'cPanel') ? 'selected' : '' }}>
cPanel cPanel
</option> </option>
<option <option
value="Direct Admin" {{ ($reseller[0]->reseller_type === 'Direct Admin') ? 'selected' : '' }}> value="Direct Admin" {{ ($reseller->reseller_type === 'Direct Admin') ? 'selected' : '' }}>
Direct Admin Direct Admin
</option> </option>
<option <option
value="Webmin" {{ ($reseller[0]->reseller_type === 'Webmin') ? 'selected' : '' }}> value="Webmin" {{ ($reseller->reseller_type === 'Webmin') ? 'selected' : '' }}>
Webmin Webmin
</option> </option>
<option <option
value="Moss" {{ ($reseller[0]->reseller_type === 'Moss') ? 'selected' : '' }}> value="Moss" {{ ($reseller->reseller_type === 'Moss') ? 'selected' : '' }}>
Moss Moss
</option> </option>
<option <option
value="Other" {{ ($reseller[0]->reseller_type === 'Other') ? 'selected' : '' }}> value="Other" {{ ($reseller->reseller_type === 'Other') ? 'selected' : '' }}>
Other Other
</option> </option>
<option <option
value="Plesk" {{ ($reseller[0]->reseller_type === 'Plesk') ? 'selected' : '' }}> value="Plesk" {{ ($reseller->reseller_type === 'Plesk') ? 'selected' : '' }}>
Plesk Plesk
</option> </option>
<option <option
value="Run cloud" {{ ($reseller[0]->reseller_type === 'Run cloud') ? 'selected' : '' }}> value="Run cloud" {{ ($reseller->reseller_type === 'Run cloud') ? 'selected' : '' }}>
Run cloud Run cloud
</option> </option>
<option <option
value="Vesta CP" {{ ($reseller[0]->reseller_type === 'Vesta CP') ? 'selected' : '' }}> value="Vesta CP" {{ ($reseller->reseller_type === 'Vesta CP') ? 'selected' : '' }}>
Vesta CP Vesta CP
</option> </option>
<option <option
value="Virtual min" {{ ($reseller[0]->reseller_type === 'Virtual min') ? 'selected' : '' }}> value="Virtual min" {{ ($reseller->reseller_type === 'Virtual min') ? 'selected' : '' }}>
Virtual min Virtual min
</option> </option>
</select> </select>
@ -84,21 +84,21 @@
<x-slot name="name">dedicated_ip</x-slot> <x-slot name="name">dedicated_ip</x-slot>
<x-slot name="max">255</x-slot> <x-slot name="max">255</x-slot>
<x-slot <x-slot
name="value">@if(isset($ip_address[0]['address'])){{$ip_address[0]['address']}}@endif</x-slot> name="value">@if(isset($reseller->ips[0]['address'])){{$reseller->ips[0]['address']}}@endif</x-slot>
</x-text-input> </x-text-input>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-providers-select> <x-providers-select>
<x-slot name="current">{{$reseller[0]->provider_id}}</x-slot> <x-slot name="current">{{$reseller->provider->id}}</x-slot>
</x-providers-select> </x-providers-select>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-number-input> <x-number-input>
<x-slot name="title">Price</x-slot> <x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot> <x-slot name="name">price</x-slot>
<x-slot name="value">{{$reseller[0]->price}}</x-slot> <x-slot name="value">{{$reseller->price->price}}</x-slot>
<x-slot name="max">9999</x-slot> <x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot> <x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot> <x-slot name="required"></x-slot>
@ -106,40 +106,40 @@
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-term-select> <x-term-select>
<x-slot name="current">{{$reseller[0]->term}}</x-slot> <x-slot name="current">{{$reseller->price->term}}</x-slot>
</x-term-select> </x-term-select>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-currency-select> <x-currency-select>
<x-slot name="current">{{$reseller[0]->currency}}</x-slot> <x-slot name="current">{{$reseller->price->currency}}</x-slot>
</x-currency-select> </x-currency-select>
</div> </div>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-locations-select> <x-locations-select>
<x-slot name="current">{{$reseller[0]->location_id}}</x-slot> <x-slot name="current">{{$reseller->location->id}}</x-slot>
</x-locations-select> </x-locations-select>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-yes-no-select> <x-yes-no-select>
<x-slot name="title">Promo price</x-slot> <x-slot name="title">Promo price</x-slot>
<x-slot name="name">was_promo</x-slot> <x-slot name="name">was_promo</x-slot>
<x-slot name="value">{{ $reseller[0]->was_promo }}</x-slot> <x-slot name="value">{{ $reseller->was_promo }}</x-slot>
</x-yes-no-select> </x-yes-no-select>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-date-input> <x-date-input>
<x-slot name="title">Owned since</x-slot> <x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot> <x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{$reseller[0]->owned_since }}</x-slot> <x-slot name="value">{{$reseller->owned_since }}</x-slot>
</x-date-input> </x-date-input>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-date-input> <x-date-input>
<x-slot name="title">Next due date</x-slot> <x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot> <x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{$reseller[0]->next_due_date }}</x-slot> <x-slot name="value">{{$reseller->price->next_due_date }}</x-slot>
</x-date-input> </x-date-input>
</div> </div>
</div> </div>
@ -152,7 +152,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->accounts}}</x-slot> <x-slot name="value">{{$reseller->accounts}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -162,7 +162,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->domains_limit}}</x-slot> <x-slot name="value">{{$reseller->domains_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -172,7 +172,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->subdomains_limit}}</x-slot> <x-slot name="value">{{$reseller->subdomains_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -182,7 +182,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->disk_as_gb}}</x-slot> <x-slot name="value">{{$reseller->disk_as_gb}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
</div> </div>
@ -194,7 +194,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->email_limit}}</x-slot> <x-slot name="value">{{$reseller->email_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -204,7 +204,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->bandwidth}}</x-slot> <x-slot name="value">{{$reseller->bandwidth}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -214,7 +214,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->ftp_limit}}</x-slot> <x-slot name="value">{{$reseller->ftp_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -224,17 +224,17 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$reseller[0]->db_limit}}</x-slot> <x-slot name="value">{{$reseller->db_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row">
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot> <x-slot name="name">label1</x-slot>
@if(isset($labels[0]->id)) @if(isset($reseller->labels[0]->label->id))
<x-slot name="current">{{$labels[0]->id}}</x-slot> <x-slot name="current">{{$reseller->labels[0]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -242,8 +242,8 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot> <x-slot name="name">label2</x-slot>
@if(isset($labels[1]->id)) @if(isset($reseller->labels[1]->label->id))
<x-slot name="current">{{$labels[1]->id}}</x-slot> <x-slot name="current">{{$reseller->labels[1]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -251,8 +251,8 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot> <x-slot name="name">label3</x-slot>
@if(isset($labels[2]->id)) @if(isset($reseller->labels[2]->label->id))
<x-slot name="current">{{$labels[2]->id}}</x-slot> <x-slot name="current">{{$reseller->labels[2]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -260,15 +260,15 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot> <x-slot name="name">label4</x-slot>
@if(isset($labels[3]->id)) @if(isset($reseller->labels[3]->label->id))
<x-slot name="current">{{$labels[3]->id}}</x-slot> <x-slot name="current">{{$reseller->labels[3]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
</div> </div>
<div class="form-check mt-2"> <div class="form-check mt-2">
<input class="form-check-input" name="is_active" type="checkbox" <input class="form-check-input" name="is_active" type="checkbox"
value="1" {{ ($reseller[0]->active === 1) ? 'checked' : '' }}> value="1" {{ ($reseller->active === 1) ? 'checked' : '' }}>
<label class="form-check-label"> <label class="form-check-label">
I still have this server I still have this server
</label> </label>

View File

@ -44,20 +44,20 @@
<td>{{ $row->main_domain }}</td> <td>{{ $row->main_domain }}</td>
<td>{{ $row->reseller_type }}</td> <td>{{ $row->reseller_type }}</td>
<td>{{ $row->accounts }}</td> <td>{{ $row->accounts }}</td>
<td class="text-nowrap">{{ $row->location }}</td> <td class="text-nowrap">{{ $row->location->name }}</td>
<td class="text-nowrap">{{ $row->provider_name }}</td> <td class="text-nowrap">{{ $row->provider->name }}</td>
<td>{{ $row->disk_as_gb }} <small>GB</small></td> <td>{{ $row->disk_as_gb }} <small>GB</small></td>
<td>{{ $row->price }} {{$row->currency}} {{\App\Process::paymentTermIntToString($row->term)}}</td> <td>{{ $row->price->price }} {{$row->price->currency}} {{\App\Process::paymentTermIntToString($row->price->term)}}</td>
<td>{{Carbon\Carbon::parse($row->next_due_date)->diffForHumans()}}</td> <td>{{Carbon\Carbon::parse($row->price->next_due_date)->diffForHumans()}}</td>
<td class="text-nowrap">{{ $row->owned_since }}</td> <td class="text-nowrap">{{ $row->owned_since }}</td>
<td class="text-nowrap"> <td class="text-nowrap">
<form action="{{ route('reseller.destroy', $row->service_id) }}" method="POST"> <form action="{{ route('reseller.destroy', $row->id) }}" method="POST">
<a href="{{ route('reseller.show', $row->service_id) }}" <a href="{{ route('reseller.show', $row->id) }}"
class="text-body mx-1"><i class="fas fa-eye" title="view"></i></a> class="text-body mx-1"><i class="fas fa-eye" title="view"></i></a>
<a href="{{ route('reseller.edit', $row->service_id) }}" <a href="{{ route('reseller.edit', $row->id) }}"
class="text-body mx-1"><i class="fas fa-pen" title="edit"></i></a> class="text-body mx-1"><i class="fas fa-pen" title="edit"></i></a>
<i class="fas fa-trash text-danger ms-3" @click="modalForm" <i class="fas fa-trash text-danger ms-3" @click="modalForm"
id="btn-{{$row->main_domain}}" title="{{$row->service_id}}"></i> id="btn-{{$row->main_domain}}" title="{{$row->id}}"></i>
</form> </form>
</td> </td>
</tr> </tr>

View File

@ -8,13 +8,9 @@
<div class="row"> <div class="row">
<div class="col-12 col-md-6 mb-2"> <div class="col-12 col-md-6 mb-2">
<h2>{{ $reseller->main_domain }}</h2> <h2>{{ $reseller->main_domain }}</h2>
<code>@foreach($labels as $label) @foreach($reseller->labels as $label)
@if($loop->last) <span class="badge bg-primary mx-1">{{$label->label->label}}</span>
{{$label->label}} @endforeach
@else
{{$label->label}},
@endif
@endforeach</code>
</div> </div>
<div class="col-12 col-md-6 text-md-end"> <div class="col-12 col-md-6 text-md-end">
<h6 class="text-muted pe-lg-4">{{ $reseller->id }}</h6> <h6 class="text-muted pe-lg-4">{{ $reseller->id }}</h6>
@ -30,7 +26,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Type</td> <td class="px-2 py-2 font-bold text-muted">Type</td>
<td>{{ $reseller_extras[0]->reseller_type }}</td> <td>{{ $reseller->reseller_type }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Main domain</td> <td class="px-2 py-2 font-bold text-muted">Main domain</td>
@ -39,22 +35,22 @@
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Location</td> <td class="px-2 py-2 font-bold text-muted">Location</td>
<td>{{ $reseller_extras[0]->location }}</td> <td>{{ $reseller->location->name }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Provider</td> <td class="px-2 py-2 font-bold text-muted">Provider</td>
<td>{{ $reseller_extras[0]->provider_name }}</td> <td>{{ $reseller->provider->name }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Price</td> <td class="px-2 py-2 font-bold text-muted">Price</td>
<td>{{ $reseller_extras[0]->price }} {{ $reseller_extras[0]->currency }} <td>{{ $reseller->price->price }} {{ $reseller->price->currency }}
<small>{{\App\Process::paymentTermIntToString($reseller_extras[0]->term)}}</small> <small>{{\App\Process::paymentTermIntToString($reseller->price->term)}}</small>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Has dedicated IP?</td> <td class="px-2 py-2 font-bold text-muted">Has dedicated IP?</td>
<td> <td>
@if(isset($ip_address[0]->address)) @if(isset($reseller->ips[0]->address))
Yes Yes
@else @else
No No
@ -63,8 +59,8 @@
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">IP</td> <td class="px-2 py-2 font-bold text-muted">IP</td>
<td><code>@if(isset($ip_address[0]->address)) <td><code>@if(isset($reseller->ips[0]->address))
{{$ip_address[0]->address}} {{$reseller->ips[0]->address}}
@endif @endif
</code></td> </code></td>
</tr> </tr>
@ -78,8 +74,8 @@
</tr> </tr>
<tr> <tr>
<td class="px-2 py-2 font-bold text-muted">Next due date</td> <td class="px-2 py-2 font-bold text-muted">Next due date</td>
<td>{{Carbon\Carbon::parse($reseller_extras[0]->next_due_date)->diffForHumans()}} <td>{{Carbon\Carbon::parse($reseller->price->next_due_date)->diffForHumans()}}
({{Carbon\Carbon::parse($reseller_extras[0]->next_due_date)->format('d/m/Y')}}) ({{Carbon\Carbon::parse($reseller->price->next_due_date)->format('d/m/Y')}})
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -1,7 +1,7 @@
@section('title') {{$shared[0]->main_domain}} {{'edit'}} @endsection @section('title') {{$shared->main_domain}} {{'edit'}} @endsection
<x-app-layout> <x-app-layout>
<x-slot name="header"> <x-slot name="header">
Edit {{ $shared[0]->main_domain }} Edit {{ $shared->main_domain }}
</x-slot> </x-slot>
<div class="container"> <div class="container">
@ -12,7 +12,7 @@
Back to shared hosting Back to shared hosting
</a> </a>
<x-auth-validation-errors></x-auth-validation-errors> <x-auth-validation-errors></x-auth-validation-errors>
<form action="{{ route('shared.update', $shared[0]->id) }}" method="POST"> <form action="{{ route('shared.update', $shared->id) }}" method="POST">
@csrf @csrf
@method('PUT') @method('PUT')
<div class="row mt-3"> <div class="row mt-3">
@ -21,55 +21,55 @@
<div class="input-group-prepend"><span class="input-group-text">Domain</span></div> <div class="input-group-prepend"><span class="input-group-text">Domain</span></div>
<input type="text" <input type="text"
class="form-control" class="form-control"
name="domain" value="{{$shared[0]->main_domain}}"> name="domain" value="{{$shared->main_domain}}">
@error('name') <span class="text-red-500">{{ $message }} @error('name') <span class="text-red-500">{{ $message }}
</span>@enderror </span>@enderror
</div> </div>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<input type="hidden" name="id" value="{{$shared[0]->id}}"> <input type="hidden" name="id" value="{{$shared->id}}">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div> <div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" id="shared_type" name="shared_type"> <select class="form-control" id="shared_type" name="shared_type">
<option <option
value="ApisCP" {{ ($shared[0]->shared_type === 'ApisCP') ? 'selected' : '' }}> value="ApisCP" {{ ($shared->shared_type === 'ApisCP') ? 'selected' : '' }}>
ApisCP ApisCP
</option> </option>
<option <option
value="Centos" {{ ($shared[0]->shared_type === 'Centos') ? 'selected' : '' }}> value="Centos" {{ ($shared->shared_type === 'Centos') ? 'selected' : '' }}>
Centos Centos
</option> </option>
<option <option
value="cPanel" {{ ($shared[0]->shared_type === 'cPanel') ? 'selected' : '' }}> value="cPanel" {{ ($shared->shared_type === 'cPanel') ? 'selected' : '' }}>
cPanel cPanel
</option> </option>
<option <option
value="Direct Admin" {{ ($shared[0]->shared_type === 'Direct Admin') ? 'selected' : '' }}> value="Direct Admin" {{ ($shared->shared_type === 'Direct Admin') ? 'selected' : '' }}>
Direct Admin Direct Admin
</option> </option>
<option <option
value="Webmin" {{ ($shared[0]->shared_type === 'Webmin') ? 'selected' : '' }}> value="Webmin" {{ ($shared->shared_type === 'Webmin') ? 'selected' : '' }}>
Webmin Webmin
</option> </option>
<option value="Moss" {{ ($shared[0]->shared_type === 'Moss') ? 'selected' : '' }}> <option value="Moss" {{ ($shared->shared_type === 'Moss') ? 'selected' : '' }}>
Moss Moss
</option> </option>
<option value="Other" {{ ($shared[0]->shared_type === 'Other') ? 'selected' : '' }}> <option value="Other" {{ ($shared->shared_type === 'Other') ? 'selected' : '' }}>
Other Other
</option> </option>
<option value="Plesk" {{ ($shared[0]->shared_type === 'Plesk') ? 'selected' : '' }}> <option value="Plesk" {{ ($shared->shared_type === 'Plesk') ? 'selected' : '' }}>
Plesk Plesk
</option> </option>
<option <option
value="Run cloud" {{ ($shared[0]->shared_type === 'Run cloud') ? 'selected' : '' }}> value="Run cloud" {{ ($shared->shared_type === 'Run cloud') ? 'selected' : '' }}>
Run cloud Run cloud
</option> </option>
<option <option
value="Vesta CP" {{ ($shared[0]->shared_type === 'Vesta CP') ? 'selected' : '' }}> value="Vesta CP" {{ ($shared->shared_type === 'Vesta CP') ? 'selected' : '' }}>
Vesta CP Vesta CP
</option> </option>
<option <option
value="Virtual min" {{ ($shared[0]->shared_type === 'Virtual min') ? 'selected' : '' }}> value="Virtual min" {{ ($shared->shared_type === 'Virtual min') ? 'selected' : '' }}>
Virtual min Virtual min
</option> </option>
</select> </select>
@ -80,21 +80,21 @@
<x-slot name="title">Dedicated IP</x-slot> <x-slot name="title">Dedicated IP</x-slot>
<x-slot name="name">dedicated_ip</x-slot> <x-slot name="name">dedicated_ip</x-slot>
<x-slot name="max">255</x-slot> <x-slot name="max">255</x-slot>
<x-slot name="value">@if(isset($shared[0]->ips[0]->address)) {{$shared[0]->ips[0]->address}}@endif</x-slot> <x-slot name="value">@if(isset($shared->ips[0]->address)) {{$shared->ips[0]->address}}@endif</x-slot>
</x-text-input> </x-text-input>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-providers-select> <x-providers-select>
<x-slot name="current">{{$shared[0]->provider->id}}</x-slot> <x-slot name="current">{{$shared->provider->id}}</x-slot>
</x-providers-select> </x-providers-select>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-number-input> <x-number-input>
<x-slot name="title">Price</x-slot> <x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot> <x-slot name="name">price</x-slot>
<x-slot name="value">{{$shared[0]->price->price}}</x-slot> <x-slot name="value">{{$shared->price->price}}</x-slot>
<x-slot name="max">9999</x-slot> <x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot> <x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot> <x-slot name="required"></x-slot>
@ -102,40 +102,40 @@
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-term-select> <x-term-select>
<x-slot name="current">{{$shared[0]->price->term}}</x-slot> <x-slot name="current">{{$shared->price->term}}</x-slot>
</x-term-select> </x-term-select>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<x-currency-select> <x-currency-select>
<x-slot name="current">{{$shared[0]->price->currency}}</x-slot> <x-slot name="current">{{$shared->price->currency}}</x-slot>
</x-currency-select> </x-currency-select>
</div> </div>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-locations-select> <x-locations-select>
<x-slot name="current">{{$shared[0]->location->id}}</x-slot> <x-slot name="current">{{$shared->location->id}}</x-slot>
</x-locations-select> </x-locations-select>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-yes-no-select> <x-yes-no-select>
<x-slot name="title">Promo price</x-slot> <x-slot name="title">Promo price</x-slot>
<x-slot name="name">was_promo</x-slot> <x-slot name="name">was_promo</x-slot>
<x-slot name="value">{{ $shared[0]->was_promo }}</x-slot> <x-slot name="value">{{ $shared->was_promo }}</x-slot>
</x-yes-no-select> </x-yes-no-select>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-date-input> <x-date-input>
<x-slot name="title">Owned since</x-slot> <x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot> <x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{$shared[0]->owned_since }}</x-slot> <x-slot name="value">{{$shared->owned_since }}</x-slot>
</x-date-input> </x-date-input>
</div> </div>
<div class="col-12 col-md-3 mb-3"> <div class="col-12 col-md-3 mb-3">
<x-date-input> <x-date-input>
<x-slot name="title">Next due date</x-slot> <x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot> <x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{$shared[0]->price->next_due_date }}</x-slot> <x-slot name="value">{{$shared->price->next_due_date }}</x-slot>
</x-date-input> </x-date-input>
</div> </div>
</div> </div>
@ -148,7 +148,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->domains_limit}}</x-slot> <x-slot name="value">{{$shared->domains_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -158,7 +158,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->subdomains_limit}}</x-slot> <x-slot name="value">{{$shared->subdomains_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -168,7 +168,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->disk_as_gb}}</x-slot> <x-slot name="value">{{$shared->disk_as_gb}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -178,7 +178,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->email_limit}}</x-slot> <x-slot name="value">{{$shared->email_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
</div> </div>
@ -190,7 +190,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->bandwidth}}</x-slot> <x-slot name="value">{{$shared->bandwidth}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -200,7 +200,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->ftp_limit}}</x-slot> <x-slot name="value">{{$shared->ftp_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
@ -210,7 +210,7 @@
<x-slot name="value">1</x-slot> <x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot> <x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot> <x-slot name="step">1</x-slot>
<x-slot name="value">{{$shared[0]->db_limit}}</x-slot> <x-slot name="value">{{$shared->db_limit}}</x-slot>
</x-number-input> </x-number-input>
</div> </div>
</div> </div>
@ -219,8 +219,8 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot> <x-slot name="name">label1</x-slot>
@if(isset($shared[0]->labels[0]->label->id)) @if(isset($shared->labels[0]->label->id))
<x-slot name="current">{{$shared[0]->labels[0]->label->id}}</x-slot> <x-slot name="current">{{$shared->labels[0]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -228,8 +228,8 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot> <x-slot name="name">label2</x-slot>
@if(isset($shared[0]->labels[1]->label->id)) @if(isset($shared->labels[1]->label->id))
<x-slot name="current">{{$shared[0]->labels[1]->label->id}}</x-slot> <x-slot name="current">{{$shared->labels[1]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -237,8 +237,8 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot> <x-slot name="name">label3</x-slot>
@if(isset($shared[0]->labels[2]->label->id)) @if(isset($shared->labels[2]->label->id))
<x-slot name="current">{{$shared[0]->labels[2]->label->id}}</x-slot> <x-slot name="current">{{$shared->labels[2]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
@ -246,15 +246,15 @@
<x-labels-select> <x-labels-select>
<x-slot name="title">label</x-slot> <x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot> <x-slot name="name">label4</x-slot>
@if(isset($shared[0]->labels[3]->label->id)) @if(isset($shared->labels[3]->label->id))
<x-slot name="current">{{$shared[0]->labels[3]->label->id}}</x-slot> <x-slot name="current">{{$shared->labels[3]->label->id}}</x-slot>
@endif @endif
</x-labels-select> </x-labels-select>
</div> </div>
</div> </div>
<div class="form-check mt-2"> <div class="form-check mt-2">
<input class="form-check-input" name="is_active" type="checkbox" <input class="form-check-input" name="is_active" type="checkbox"
value="1" {{ ($shared[0]->active === 1) ? 'checked' : '' }}> value="1" {{ ($shared->active === 1) ? 'checked' : '' }}>
<label class="form-check-label"> <label class="form-check-label">
I still have this server I still have this server
</label> </label>