Updated destroy() methods for delete condition

Updated destroy() methods for delete condition
If not true then return with the error alert
This commit is contained in:
cp6 2022-11-09 15:18:25 +11:00
parent 43d22f8e16
commit e31a785844
13 changed files with 121 additions and 79 deletions

View File

@ -123,13 +123,16 @@ class DNSController extends Controller
public function destroy(DNS $dn)
{
$dn->delete();
if ( $dn->delete()){
Cache::forget('dns_count');
Cache::forget('dns_count');
Labels::deleteLabelsAssignedTo($dn->id);
Labels::deleteLabelsAssignedTo($dn->id);
return redirect()->route('dns.index')
->with('success', 'DNS was deleted Successfully.');
}
return redirect()->route('dns.index')
->with('success', 'DNS was deleted Successfully.');
->with('error', 'DNS was not deleted.');
}
}

View File

@ -127,19 +127,22 @@ class DomainsController extends Controller
public function destroy(Domains $domain)
{
$domain->delete();
if ($domain->delete()){
$p = new Pricing();
$p->deletePricing($domain->id);
$p = new Pricing();
$p->deletePricing($domain->id);
Labels::deleteLabelsAssignedTo($domain->id);
Labels::deleteLabelsAssignedTo($domain->id);
Cache::forget("all_domains");
Cache::forget("domain.{$domain->id}");
Home::homePageCacheForget();
Cache::forget("all_domains");
Cache::forget("domain.{$domain->id}");
Home::homePageCacheForget();
return redirect()->route('domains.index')
->with('success', 'Domain was deleted Successfully.');
}
return redirect()->route('domains.index')
->with('success', 'Domain was deleted Successfully.');
->with('error', 'Domain was not deleted.');
}
}

View File

@ -53,9 +53,11 @@ class IPsController extends Controller
public function destroy(IPs $IP)
{
$IP->delete();
if ($IP->delete()) {
return redirect()->route('IPs.index')
->with('success', 'IP address was deleted Successfully.');
}
return redirect()->route('IPs.index')
->with('success', 'IP address was deleted Successfully.');
->with('error', 'IP was not deleted.');
}
}

View File

@ -61,15 +61,18 @@ class LabelsController extends Controller
public function destroy(Labels $label)
{
$label->delete();
if ($label->delete()) {
Cache::forget('labels_count');
Cache::forget('labels_count');
Labels::deleteLabelAssignedAs($label->id);
Labels::deleteLabelAssignedAs($label->id);
Cache::forget('all_labels');
Cache::forget('all_labels');
return redirect()->route('labels.index')
->with('success', 'Label was deleted Successfully.');
}
return redirect()->route('labels.index')
->with('success', 'Label was deleted Successfully.');
->with('error', 'Label was not deleted.');
}
}

View File

@ -61,11 +61,15 @@ class LocationsController extends Controller
public function destroy(Locations $location)
{
$location->delete();
if ($location->delete()){
Cache::forget('locations');
Cache::forget('locations');
return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.');
}
return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.');
->with('error', 'Location was not deleted.');
}
}

View File

@ -94,16 +94,19 @@ class MiscController extends Controller
public function destroy(Misc $misc)
{
$misc->delete();
if ($misc->delete()) {
$p = new Pricing();
$p->deletePricing($misc->id);
$p = new Pricing();
$p->deletePricing($misc->id);
Cache::forget("all_misc");
Cache::forget("misc.{$misc->id}");
Home::homePageCacheForget();
Cache::forget("all_misc");
Cache::forget("misc.{$misc->id}");
Home::homePageCacheForget();
return redirect()->route('misc.index')
->with('success', 'Misc service was deleted Successfully.');
}
return redirect()->route('misc.index')
->with('success', 'Misc service was deleted Successfully.');
->with('error', 'Misc service was not deleted.');
}
}

View File

@ -37,11 +37,15 @@ class OsController extends Controller
public function destroy(OS $o)
{
$o->delete();
if ($o->delete()) {
Cache::forget('operating_systems');
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
->with('error', 'OS was not deleted.');
}
}

View File

@ -46,12 +46,16 @@ class ProvidersController extends Controller
public function destroy(Providers $provider)
{
$provider->delete();
if ($provider->delete()) {
Cache::forget('providers');
Cache::forget('providers');
return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.');
}
return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.');
->with('error', 'Provider was not deleted.');
}
}

View File

@ -174,20 +174,24 @@ class ResellerController extends Controller
public function destroy(Reseller $reseller)
{
$reseller->delete();
if ($reseller->delete()) {
$p = new Pricing();
$p->deletePricing($reseller->id);
$p = new Pricing();
$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");
Home::homePageCacheForget();
Cache::forget("all_reseller");
Cache::forget("reseller_hosting.$reseller->id");
Home::homePageCacheForget();
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting was deleted Successfully.');
}
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting was deleted Successfully.');
->with('error', 'Reseller was not deleted.');
}
}

View File

@ -146,18 +146,21 @@ class SeedBoxesController extends Controller
public function destroy(SeedBoxes $seedbox)
{
$seedbox->delete();
if ($seedbox->delete()) {
$p = new Pricing();
$p->deletePricing($seedbox->id);
$p = new Pricing();
$p->deletePricing( $seedbox->id);
Labels::deleteLabelsAssignedTo($seedbox->id);
Labels::deleteLabelsAssignedTo( $seedbox->id);
Cache::forget("all_seedboxes");
Cache::forget("seedbox.{$seedbox->id}");
Home::homePageCacheForget();
Cache::forget("all_seedboxes");
Cache::forget("seedbox.{$seedbox->id}");
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
}
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
->with('error', 'Seed box was not deleted.');
}
}

View File

@ -199,19 +199,22 @@ class ServerController extends Controller
public function destroy(Server $server)
{
$server->delete();
if ($server->delete()) {
$p = new Pricing();
$p->deletePricing($server->id);
$p = new Pricing();
$p->deletePricing($server->id);
Labels::deleteLabelsAssignedTo($server->id);
Labels::deleteLabelsAssignedTo($server->id);
IPs::deleteIPsAssignedTo($server->id);
IPs::deleteIPsAssignedTo($server->id);
Server::serverRelatedCacheForget();
Server::serverRelatedCacheForget();
return redirect()->route('servers.index')
->with('success', 'Server was deleted Successfully.');
}
return redirect()->route('servers.index')
->with('success', 'Server was deleted Successfully.');
->with('error', 'Server was not deleted.');
}
public function chooseCompare()

View File

@ -168,21 +168,24 @@ class SharedController extends Controller
public function destroy(Shared $shared)
{
$shared->delete();
if ($shared->delete()) {
$p = new Pricing();
$p->deletePricing($shared->id);
$p = new Pricing();
$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('all_shared');
Home::homePageCacheForget();
Cache::forget("shared_hosting.$shared->id");
Cache::forget('all_shared');
Home::homePageCacheForget();
return redirect()->route('shared.index')
->with('success', 'Shared hosting was deleted Successfully.');
}
return redirect()->route('shared.index')
->with('success', 'Shared hosting was deleted Successfully.');
->with('error', 'Shared was not deleted.');
}
}

View File

@ -32,26 +32,29 @@ class YabsController extends Controller
public function destroy(Yabs $yab)
{
$yab->delete();
if ($yab->delete()) {
if (Server::serverYabsAmount($yab->server_id) === 0) {
DB::table('servers')
->where('id', $yab->server_id)
->update(['has_yabs' => 0]);
}
if (Server::serverYabsAmount($yab->server_id) === 0) {
DB::table('servers')
->where('id', $yab->server_id)
->update(['has_yabs' => 0]);
Cache::forget('all_yabs');
Cache::forget("yabs.{$yab->id}");
return redirect()->route('yabs.index')
->with('success', 'YABS was deleted Successfully.');
}
Cache::forget('all_yabs');
Cache::forget("yabs.{$yab->id}");
return redirect()->route('yabs.index')
->with('success', 'YABS was deleted Successfully.');
->with('error', 'YABS was not deleted.');
}
public function chooseYabsCompare()
{
$all_yabs = Yabs::allYabs();
if (isset($all_yabs[1])){
if (isset($all_yabs[1])) {
return view('yabs.choose-compare', compact('all_yabs'));
}