added vpn feature to mno
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\NetworkOperator;
|
||||
use App\Models\NetworkOperatorConnection;
|
||||
|
||||
class NetworkOperatorsController extends Controller
|
||||
{
|
||||
@@ -34,9 +35,10 @@ class NetworkOperatorsController extends Controller
|
||||
|
||||
$totalActive = NetworkOperator::where('connection_status', 'Active')->count();
|
||||
$totalSipLinks = NetworkOperator::where('connection_type', 'like', '%VPN%')->count();
|
||||
$uniqueCountries = $uniqueCountriesCount = NetworkOperator::distinct('country')->count('country');
|
||||
$totalOperators = NetworkOperator::count();
|
||||
|
||||
return view('network_operators.index', compact('operators', 'totalActive', 'totalSipLinks', 'totalOperators'));
|
||||
return view('network_operators.index', compact('operators', 'totalActive', 'uniqueCountries', 'totalOperators'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
@@ -111,5 +113,61 @@ class NetworkOperatorsController extends Controller
|
||||
return view('network_operators.show', compact('operator'));
|
||||
}
|
||||
|
||||
public function storeConnection(Request $request, $operatorId)
|
||||
{
|
||||
$request->validate([
|
||||
'connection_mode' => 'required|string',
|
||||
'identifier' => [
|
||||
'required',
|
||||
'string',
|
||||
function ($attribute, $value, $fail) {
|
||||
// 1. Check if valid IP Address (IPv4 or IPv6)
|
||||
$isIp = filter_var($value, FILTER_VALIDATE_IP);
|
||||
|
||||
// 2. Check if valid Domain Name (e.g., smpp.operator.com)
|
||||
$isDomain = preg_match('/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i', $value);
|
||||
|
||||
// 3. Check if valid CIDR Subnet (e.g., 196.200.15.0/24)
|
||||
$isSubnet = preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}\/([0-9]|[1-2][0-9]|3[0-2])$/', $value);
|
||||
|
||||
if (!$isIp && !$isDomain && !$isSubnet) {
|
||||
$fail('The identifier must be a valid IP address, CIDR subnet, or Domain Name.');
|
||||
}
|
||||
},
|
||||
],
|
||||
'port' => 'nullable|integer|min:1|max:65535',
|
||||
'vpn_file' => 'nullable|file|mimes:pdf,doc,docx|max:5120',
|
||||
]);
|
||||
|
||||
$filePath = null;
|
||||
if ($request->hasFile('vpn_file')) {
|
||||
$filePath = $request->file('vpn_file')->store('vpn_forms', 'public');
|
||||
}
|
||||
|
||||
$connection = NetworkOperatorConnection::create([
|
||||
'network_operator_id' => $operatorId,
|
||||
'connection_mode' => $request->connection_mode,
|
||||
'identifier' => $request->identifier,
|
||||
'port' => $request->port,
|
||||
'status' => $request->status ?? 'Active',
|
||||
'notes' => $request->notes,
|
||||
'vpn_file_path' => $filePath,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Connection detail added successfully!',
|
||||
'connection' => $connection
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroyConnection($id)
|
||||
{
|
||||
$connection = NetworkOperatorConnection::findOrFail($id);
|
||||
$connection->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Connection detail removed.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user