2022-02-21 01:17:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2022-02-21 04:47:36 +01:00
|
|
|
use App\Models\DNS;
|
2022-02-21 01:23:40 +01:00
|
|
|
use App\Models\IPs;
|
2022-02-21 01:57:04 +01:00
|
|
|
use App\Models\Reseller;
|
|
|
|
use App\Models\Server;
|
|
|
|
use App\Models\Shared;
|
2022-02-21 01:17:59 +01:00
|
|
|
use Illuminate\Http\Request;
|
2022-02-21 01:23:40 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2022-02-21 04:47:36 +01:00
|
|
|
use Illuminate\Support\Str;
|
2022-02-21 01:17:59 +01:00
|
|
|
|
|
|
|
class IPsController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2022-02-21 01:23:40 +01:00
|
|
|
$ips = IPs::all();
|
2022-02-21 01:57:04 +01:00
|
|
|
return view('ips.index', compact(['ips']));
|
2022-02-21 01:17:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function create()
|
|
|
|
{
|
2022-02-21 01:57:04 +01:00
|
|
|
$Servers = Server::all();
|
|
|
|
$Shareds = Shared::all();
|
|
|
|
$Resellers = Reseller::all();
|
|
|
|
return view('ips.create', compact(['Servers', 'Shareds', 'Resellers']));
|
2022-02-21 01:17:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2022-02-21 04:47:36 +01:00
|
|
|
$request->validate([
|
|
|
|
'address' => 'required|ip|min:2',
|
2022-10-20 02:06:44 +02:00
|
|
|
'ip_type' => 'required|string|size:4',
|
|
|
|
'service_id' => 'required|string'
|
2022-02-21 04:47:36 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
$ip_id = Str::random(8);
|
|
|
|
|
|
|
|
IPs::create([
|
|
|
|
'id' => $ip_id,
|
|
|
|
'address' => $request->address,
|
|
|
|
'is_ipv4' => ($request->ip_type === 'ipv4') ? 1 : 0,
|
|
|
|
'service_id' => $request->service_id,
|
|
|
|
'active' => 1
|
|
|
|
]);
|
|
|
|
|
|
|
|
return redirect()->route('IPs.index')
|
|
|
|
->with('success', 'IP address created Successfully.');
|
2022-02-21 01:17:59 +01:00
|
|
|
}
|
|
|
|
|
2022-02-21 04:47:36 +01:00
|
|
|
public function destroy(IPs $IP)
|
2022-02-21 01:17:59 +01:00
|
|
|
{
|
2022-11-08 01:14:07 +01:00
|
|
|
$IP->delete();
|
2022-02-21 01:17:59 +01:00
|
|
|
|
2022-02-21 04:47:36 +01:00
|
|
|
return redirect()->route('IPs.index')
|
|
|
|
->with('success', 'IP address was deleted Successfully.');
|
2022-02-21 01:17:59 +01:00
|
|
|
}
|
|
|
|
}
|