update
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Module\IPPool\IPPoolRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleIPPoolController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public IPPoolRepositoryInterface $ipPoolRepository
|
||||
) {
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$modules = $this->ipPoolRepository->filter(
|
||||
[
|
||||
'page' => $request->get('page') ?? 1
|
||||
]
|
||||
);
|
||||
$title = 'List all server ip pool';
|
||||
return view('admin.module.ippool.index', compact('modules', 'title'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$title = 'Add new server ip pool';
|
||||
return view('admin.module.ippool.add', compact('title'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$ipAddresses = explode(',', $data['ip_address']);
|
||||
$moduleNetworkId = $data['module_network_id'];
|
||||
|
||||
foreach ($ipAddresses as $ip) {
|
||||
$this->ipPoolRepository->create([
|
||||
'ip_address' => trim($ip),
|
||||
'module_network_id' => $moduleNetworkId,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('module.ippool.index')->with('success', 'Add new server ip pool success');
|
||||
}
|
||||
|
||||
public function edit(int $id = 0)
|
||||
{
|
||||
$module = $this->ipPoolRepository->find($id);
|
||||
$title = 'Edit server ip pool';
|
||||
return view('admin.module.ippool.edit', compact('module', 'title'));
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id = 0)
|
||||
{
|
||||
$this->ipPoolRepository->update($id, $request->all());
|
||||
}
|
||||
|
||||
public function destroy(int $id = 0)
|
||||
{
|
||||
$this->ipPoolRepository->delete($id);
|
||||
return redirect()->route('module.ippool.index')->with('success', 'Delete server ip pool success');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user