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,8 +123,7 @@ class DNSController extends Controller
public function destroy(DNS $dn)
{
$dn->delete();
if ( $dn->delete()){
Cache::forget('dns_count');
Labels::deleteLabelsAssignedTo($dn->id);
@ -132,4 +131,8 @@ class DNSController extends Controller
return redirect()->route('dns.index')
->with('success', 'DNS was deleted Successfully.');
}
return redirect()->route('dns.index')
->with('error', 'DNS was not deleted.');
}
}

View File

@ -127,8 +127,7 @@ class DomainsController extends Controller
public function destroy(Domains $domain)
{
$domain->delete();
if ($domain->delete()){
$p = new Pricing();
$p->deletePricing($domain->id);
@ -142,4 +141,8 @@ class DomainsController extends Controller
->with('success', 'Domain was deleted Successfully.');
}
return redirect()->route('domains.index')
->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('error', 'IP was not deleted.');
}
}

View File

@ -61,8 +61,7 @@ class LabelsController extends Controller
public function destroy(Labels $label)
{
$label->delete();
if ($label->delete()) {
Cache::forget('labels_count');
Labels::deleteLabelAssignedAs($label->id);
@ -72,4 +71,8 @@ class LabelsController extends Controller
return redirect()->route('labels.index')
->with('success', 'Label was deleted Successfully.');
}
return redirect()->route('labels.index')
->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');
return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.');
}
return redirect()->route('locations.index')
->with('error', 'Location was not deleted.');
}
}

View File

@ -94,8 +94,7 @@ class MiscController extends Controller
public function destroy(Misc $misc)
{
$misc->delete();
if ($misc->delete()) {
$p = new Pricing();
$p->deletePricing($misc->id);
@ -106,4 +105,8 @@ class MiscController extends Controller
return redirect()->route('misc.index')
->with('success', 'Misc service was deleted Successfully.');
}
return redirect()->route('misc.index')
->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');
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
return redirect()->route('os.index')
->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');
return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.');
}
return redirect()->route('providers.index')
->with('error', 'Provider was not deleted.');
}
}

View File

@ -174,8 +174,7 @@ class ResellerController extends Controller
public function destroy(Reseller $reseller)
{
$reseller->delete();
if ($reseller->delete()) {
$p = new Pricing();
$p->deletePricing($reseller->id);
@ -190,4 +189,9 @@ class ResellerController extends Controller
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting was deleted Successfully.');
}
return redirect()->route('reseller.index')
->with('error', 'Reseller was not deleted.');
}
}

View File

@ -146,12 +146,11 @@ class SeedBoxesController extends Controller
public function destroy(SeedBoxes $seedbox)
{
$seedbox->delete();
if ($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}");
@ -160,4 +159,8 @@ class SeedBoxesController extends Controller
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
}
return redirect()->route('seedboxes.index')
->with('error', 'Seed box was not deleted.');
}
}

View File

@ -199,8 +199,7 @@ class ServerController extends Controller
public function destroy(Server $server)
{
$server->delete();
if ($server->delete()) {
$p = new Pricing();
$p->deletePricing($server->id);
@ -214,6 +213,10 @@ class ServerController extends Controller
->with('success', 'Server was deleted Successfully.');
}
return redirect()->route('servers.index')
->with('error', 'Server was not deleted.');
}
public function chooseCompare()
{//NOTICE: Selecting servers is not cached yet
$all_servers = Server::where('has_yabs', 1)->get();

View File

@ -168,8 +168,7 @@ class SharedController extends Controller
public function destroy(Shared $shared)
{
$shared->delete();
if ($shared->delete()) {
$p = new Pricing();
$p->deletePricing($shared->id);
@ -185,4 +184,8 @@ class SharedController extends Controller
->with('success', 'Shared hosting was deleted Successfully.');
}
return redirect()->route('shared.index')
->with('error', 'Shared was not deleted.');
}
}

View File

@ -32,8 +32,7 @@ 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)
@ -47,11 +46,15 @@ class YabsController extends Controller
->with('success', 'YABS was deleted Successfully.');
}
return redirect()->route('yabs.index')
->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'));
}