orderBy('platform_instance_id') ->orderBy('name') ->get(); return view('pages.channels.index', compact('channels')); } public function create(): View { $instances = PlatformInstance::where('is_active', true) ->orderBy('name') ->get(); return view('pages.channels.create', compact('instances')); } public function store(Request $request): RedirectResponse { $validated = $request->validate([ 'platform_instance_id' => 'required|exists:platform_instances,id', 'name' => 'required|string|max:255', 'display_name' => 'required|string|max:255', 'channel_id' => 'required|string|max:255', 'description' => 'nullable|string', ]); PlatformChannel::create($validated); return redirect()->route('channels.index') ->with('success', 'Channel created successfully!'); } public function edit(PlatformChannel $channel): View { $instances = PlatformInstance::where('is_active', true) ->orderBy('name') ->get(); return view('pages.channels.edit', compact('channel', 'instances')); } public function update(Request $request, PlatformChannel $channel): RedirectResponse { $validated = $request->validate([ 'platform_instance_id' => 'required|exists:platform_instances,id', 'name' => 'required|string|max:255', 'display_name' => 'required|string|max:255', 'channel_id' => 'required|string|max:255', 'description' => 'nullable|string', ]); $channel->update($validated); return redirect()->route('channels.index') ->with('success', 'Channel updated successfully!'); } public function destroy(PlatformChannel $channel): RedirectResponse { $channel->delete(); return redirect()->route('channels.index') ->with('success', 'Channel deleted successfully!'); } }