Updated label and DNS count to use cache
Updated label and DNS count to use cache
This commit is contained in:
parent
3ff6cfe56e
commit
779412a8da
|
@ -10,6 +10,7 @@ use App\Models\Domains;
|
|||
use App\Models\Shared;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
@ -59,6 +60,8 @@ class DNSController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
Cache::forget('dns_count');
|
||||
|
||||
return redirect()->route('dns.index')
|
||||
->with('success', 'DNS Created Successfully.');
|
||||
}
|
||||
|
@ -87,7 +90,7 @@ class DNSController extends Controller
|
|||
->where('l.service_id', '=', $dn->id)
|
||||
->get(['labels.id', 'labels.label']);
|
||||
|
||||
return view('dns.edit', compact(['dn', 'labels','Servers', 'Domains', 'Shareds', 'Resellers']));
|
||||
return view('dns.edit', compact(['dn', 'labels', 'Servers', 'Domains', 'Shareds', 'Resellers']));
|
||||
}
|
||||
|
||||
public function update(Request $request, DNS $dn)
|
||||
|
@ -130,6 +133,8 @@ class DNSController extends Controller
|
|||
|
||||
$items->delete();
|
||||
|
||||
Cache::forget('dns_count');
|
||||
|
||||
Labels::deleteLabelsAssignedTo($id);
|
||||
|
||||
return redirect()->route('dns.index')
|
||||
|
|
|
@ -34,6 +34,7 @@ class LabelsController extends Controller
|
|||
]);
|
||||
|
||||
Cache::forget('all_labels');
|
||||
Cache::forget('labels_count');
|
||||
|
||||
return redirect()->route('labels.index')
|
||||
->with('success', 'Label Created Successfully.');
|
||||
|
@ -66,6 +67,8 @@ class LabelsController extends Controller
|
|||
|
||||
$items->delete();
|
||||
|
||||
Cache::forget('labels_count');
|
||||
|
||||
Labels::deleteLabelAssignedAs($label_id);
|
||||
|
||||
Cache::forget('all_labels');
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DNS extends Model
|
||||
{
|
||||
|
@ -14,4 +16,11 @@ class DNS extends Model
|
|||
protected $fillable = ['id', 'service_id', 'hostname', 'dns_type', 'address', 'server_id', 'domain_id'];
|
||||
|
||||
public static $dns_types = ['A', 'AAAA', 'DNAME', 'MX', 'NS', 'SOA', 'TXT', 'URI'];
|
||||
|
||||
public static function dnsCount()
|
||||
{
|
||||
return Cache::remember('dns_count', now()->addMonth(1), function () {
|
||||
return DB::table('d_n_s')->count();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Labels extends Model
|
||||
|
@ -33,4 +34,11 @@ class Labels extends Model
|
|||
}
|
||||
}
|
||||
|
||||
public static function labelsCount()
|
||||
{
|
||||
return Cache::remember('labels_count', now()->addMonth(1), function () {
|
||||
return DB::table('labels')->count();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user