user roles, bug fixes

This commit is contained in:
Kwesi Banson
2026-10-13 14:29:40 +00:00
parent 40162f3080
commit 8428d94abd
14 changed files with 366 additions and 9 deletions

View File

@@ -118,8 +118,12 @@ class NetworkOperatorsController extends Controller
public function show($id)
{
$operator = NetworkOperator::findOrFail($id);
// Fetch all services for the dropdown
$allServices = \App\Models\Service::orderBy('name')->get();
$staffMembers = \App\Models\StaffMember::orderBy('name')->get();
return view('network_operators.show', compact('operator', 'staffMembers'));
return view('network_operators.show', compact('operator', 'staffMembers', 'allServices'));
}
public function storeConnection(Request $request, $operatorId)
@@ -169,6 +173,42 @@ class NetworkOperatorsController extends Controller
'connection' => $connection
]);
}
public function storeNote(Request $request, $operatorId)
{
$request->validate([
'notes_body' => 'required|string',
'services' => 'nullable|string|max:200'
]);
$serviceName = null;
if ($request->filled('services')) {
// This will find the service if it exists, or create a new one in the database if the user typed a new tag
$service = \App\Models\Service::firstOrCreate([
'name' => trim($request->services)
]);
$serviceName = $service->name;
}
\App\Models\MnoNote::create([
'mno_id' => $operatorId,
'services' => $request->services ?? '',
'user_id' => auth()->id(), // Automatically assign the logged-in user
'notes_body' => $request->notes_body,
]);
return response()->json([
'success' => true,
'message' => 'Note added successfully!'
]);
}
public function destroyNote($id)
{
$note = \App\Models\MnoNote::findOrFail($id);
$note->delete();
return redirect()->back()->with('success', 'Note deleted successfully.');
}
public function destroyConnection($id)
{