update dns
This commit is contained in:
@@ -16,12 +16,14 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class ModuleDNSController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public DnsServerRepositoryInterface $dnsServerRepository
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
// show all hosting module
|
||||
public function index(Request $request)
|
||||
{
|
||||
@@ -50,7 +52,7 @@ class ModuleDNSController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($allData) || (isset($allData) && count($allData) < 1)) {
|
||||
if (!isset($allData) || (isset($allData) && count($allData) < 1)) {
|
||||
return back()->withErrors('No data imported');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
@@ -80,7 +82,7 @@ class ModuleDNSController extends Controller
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$data = $request->all();
|
||||
$data['password'] = SignRSA::EncryptFunc($request->password);
|
||||
$data['password'] = SignRSA::EncryptFunc($request->password);
|
||||
$this->dnsServerRepository->create($data);
|
||||
DB::commit();
|
||||
} catch (\Exception $error) {
|
||||
@@ -92,7 +94,8 @@ class ModuleDNSController extends Controller
|
||||
public function edit(int $id = 0)
|
||||
{
|
||||
$server = $this->dnsServerRepository->find($id);
|
||||
if (! $server) return back()->withErrors('Can\'t find server by id ' . $server);
|
||||
if (!$server)
|
||||
return back()->withErrors('Can\'t find server by id ' . $server);
|
||||
$title = 'View server dns information';
|
||||
return view('administrator.pages.module.dns.edit', compact('title', 'server'));
|
||||
}
|
||||
@@ -100,7 +103,8 @@ class ModuleDNSController extends Controller
|
||||
{
|
||||
$server = $this->dnsServerRepository->find($id);
|
||||
|
||||
if (! $server) return back()->withErrors('Invalid Request');
|
||||
if (!$server)
|
||||
return back()->withErrors('Invalid Request');
|
||||
|
||||
$request->validated();
|
||||
|
||||
@@ -114,8 +118,8 @@ class ModuleDNSController extends Controller
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$data = $request->all();
|
||||
if (! empty($request->get('password'))) {
|
||||
$data['password'] = SignRSA::EncryptFunc($request->password);
|
||||
if (!empty($request->get('password'))) {
|
||||
$data['password'] = SignRSA::EncryptFunc($request->password);
|
||||
}
|
||||
$this->dnsServerRepository->update($id, $data);
|
||||
DB::commit();
|
||||
@@ -128,7 +132,7 @@ class ModuleDNSController extends Controller
|
||||
public function destroy(int $id = 0)
|
||||
{
|
||||
$server = $this->dnsServerRepository->find($id);
|
||||
if (! $server) {
|
||||
if (!$server) {
|
||||
return back()->withErrors('Invalid Request');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
@@ -142,4 +146,31 @@ class ModuleDNSController extends Controller
|
||||
}
|
||||
return redirect()->route('module.dns.index')->with('success', 'Deleted successfully.');
|
||||
}
|
||||
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
$query = $this->dnsServerRepository->filter(
|
||||
$request->all(),
|
||||
[],
|
||||
[],
|
||||
['*'],
|
||||
true
|
||||
);
|
||||
|
||||
return DataTables::eloquent($query)
|
||||
->addColumn(
|
||||
'action',
|
||||
function ($d) {
|
||||
return view('administrator.pages.module.dns.datatable.action', ['row' => $d])->render();
|
||||
}
|
||||
)
|
||||
->filterColumn('name', function ($query, $keyword) {
|
||||
$query->where('name', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('user', function ($query, $keyword) {
|
||||
$query->where('user', 'like', "%{$keyword}%");
|
||||
})
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user