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;
|
2022-11-09 05:05:55 +01:00
|
|
|
use App\Models\SeedBoxes;
|
2022-02-21 01:57:04 +01:00
|
|
|
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-11-09 05:05:55 +01:00
|
|
|
$servers = Server::all();
|
|
|
|
$shareds = Shared::all();
|
|
|
|
$resellers = Reseller::all();
|
|
|
|
$seed_boxes = SeedBoxes::all();
|
|
|
|
return view('ips.create', compact(['servers', 'shareds', 'resellers', 'seed_boxes']));
|
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-09 05:18:25 +01:00
|
|
|
if ($IP->delete()) {
|
|
|
|
return redirect()->route('IPs.index')
|
|
|
|
->with('success', 'IP address was deleted Successfully.');
|
|
|
|
}
|
2022-02-21 04:47:36 +01:00
|
|
|
return redirect()->route('IPs.index')
|
2022-11-09 05:18:25 +01:00
|
|
|
->with('error', 'IP was not deleted.');
|
2022-02-21 01:17:59 +01:00
|
|
|
}
|
|
|
|
}
|