Updated all destroy() methods

Updated all destroy() methods to directly delete the resource rather than fetch from database which turns out is not needed
This commit is contained in:
cp6 2022-11-08 11:14:07 +11:00
parent 74691a6ed8
commit 3bd9d5890c
14 changed files with 25 additions and 57 deletions

View File

@ -123,14 +123,11 @@ class DNSController extends Controller
public function destroy(DNS $dn)
{
$id = $dn->id;
$items = DNS::find($id);
$items->delete();
$dn->delete();
Cache::forget('dns_count');
Labels::deleteLabelsAssignedTo($id);
Labels::deleteLabelsAssignedTo($dn->id);
return redirect()->route('dns.index')
->with('success', 'DNS was deleted Successfully.');

View File

@ -127,8 +127,7 @@ class DomainsController extends Controller
public function destroy(Domains $domain)
{
$items = Domains::find($domain->id);
$items->delete();
$domain->delete();
$p = new Pricing();
$p->deletePricing($domain->id);

View File

@ -51,8 +51,7 @@ class IPsController extends Controller
public function destroy(IPs $IP)
{
$items = IPs::find($IP->id);
$items->delete();
$IP->delete();
return redirect()->route('IPs.index')
->with('success', 'IP address was deleted Successfully.');

View File

@ -61,15 +61,11 @@ class LabelsController extends Controller
public function destroy(Labels $label)
{
$label_id = $label->id;
$items = Labels::find($label_id);
$items->delete();
$label->delete();
Cache::forget('labels_count');
Labels::deleteLabelAssignedAs($label_id);
Labels::deleteLabelAssignedAs($label->id);
Cache::forget('all_labels');

View File

@ -61,9 +61,7 @@ class LocationsController extends Controller
public function destroy(Locations $location)
{
$items = Locations::find($location->id);
$items->delete();
$location->delete();
Cache::forget('locations');

View File

@ -94,8 +94,7 @@ class MiscController extends Controller
public function destroy(Misc $misc)
{
$items = Misc::find($misc->id);
$items->delete();
$misc->delete();
$p = new Pricing();
$p->deletePricing($misc->id);

View File

@ -37,9 +37,7 @@ class OsController extends Controller
public function destroy(OS $o)
{
$items = OS::find($o->id);
$items->delete();
$o->delete();
Cache::forget('operating_systems');

View File

@ -7,13 +7,5 @@ use Illuminate\Http\Request;
class PricingController extends Controller
{
public function index()
{
//
}
public function destroy(Pricing $pricing)
{
//
}
}

View File

@ -46,9 +46,7 @@ class ProvidersController extends Controller
public function destroy(Providers $provider)
{
$items = Providers::find($provider->id);
$items->delete();
$provider->delete();
Cache::forget('providers');

View File

@ -174,19 +174,17 @@ class ResellerController extends Controller
public function destroy(Reseller $reseller)
{
$reseller_id = $reseller->id;
$items = Reseller::find($reseller_id);
$items->delete();
$reseller->delete();
$p = new Pricing();
$p->deletePricing($reseller_id);
$p->deletePricing($reseller->id);
Labels::deleteLabelsAssignedTo($reseller_id);
Labels::deleteLabelsAssignedTo($reseller->id);
IPs::deleteIPsAssignedTo($reseller_id);
IPs::deleteIPsAssignedTo($reseller->id);
Cache::forget("all_reseller");
Cache::forget("reseller_hosting.$reseller_id");
Cache::forget("reseller_hosting.$reseller->id");
Home::homePageCacheForget();
return redirect()->route('reseller.index')

View File

@ -146,14 +146,12 @@ class SeedBoxesController extends Controller
public function destroy(SeedBoxes $seedbox)
{
$seedbox_id = $seedbox->id;
$items = SeedBoxes::find($seedbox_id);
$items->delete();
$seedbox->delete();
$p = new Pricing();
$p->deletePricing($seedbox_id);
$p->deletePricing( $seedbox->id);
Labels::deleteLabelsAssignedTo($seedbox_id);
Labels::deleteLabelsAssignedTo( $seedbox->id);
Cache::forget("all_seedboxes");
Cache::forget("seedbox.{$seedbox->id}");

View File

@ -199,8 +199,7 @@ class ServerController extends Controller
public function destroy(Server $server)
{
$item = Server::find($server->id);
$item->delete();
$server->delete();
$p = new Pricing();
$p->deletePricing($server->id);

View File

@ -168,18 +168,16 @@ class SharedController extends Controller
public function destroy(Shared $shared)
{
$shared_id = $shared->id;
$items = Shared::find($shared_id);
$items->delete();
$shared->delete();
$p = new Pricing();
$p->deletePricing($shared_id);
$p->deletePricing($shared->id);
Labels::deleteLabelsAssignedTo($shared_id);
Labels::deleteLabelsAssignedTo($shared->id);
IPs::deleteIPsAssignedTo($shared_id);
IPs::deleteIPsAssignedTo($shared->id);
Cache::forget("shared_hosting.$shared_id");
Cache::forget("shared_hosting.$shared->id");
Cache::forget('all_shared');
Home::homePageCacheForget();

View File

@ -32,8 +32,7 @@ class YabsController extends Controller
public function destroy(Yabs $yab)
{
$yabs = Yabs::find($yab->id);
$yabs->delete();
$yab->delete();
if (Server::serverYabsAmount($yab->server_id) === 0) {
DB::table('servers')