Stack::with('endpoint')->orderBy('name')->paginate(20), 'endpoints' => DockerEndpoint::all(), ]); } public function create() { return Inertia::render('Container/StackCreate', ['endpoints' => DockerEndpoint::all()]); } public function store(Request $request) { $validated = $request->validate([ 'name' => 'required|string|max:100', 'endpoint_id' => 'required|exists:docker_endpoints,id', 'compose_content' => 'required|string', 'env_vars' => 'nullable|array', ]); Stack::create([...$validated, 'created_by' => auth()->id()]); return redirect()->route('stacks.index')->with('success', 'Stack created.'); } public function show(Stack $stack) { return Inertia::render('Container/StackShow', ['stack' => $stack->load('endpoint')]); } public function edit(Stack $stack) { return Inertia::render('Container/StackEdit', ['stack' => $stack, 'endpoints' => DockerEndpoint::all()]); } public function update(Request $request, Stack $stack) { $stack->update($request->only('name', 'compose_content', 'env_vars')); return redirect()->route('stacks.show', $stack)->with('success', 'Stack updated.'); } public function destroy(Stack $stack) { $stack->delete(); return redirect()->route('stacks.index')->with('success', 'Stack deleted.'); } public function deploy(Stack $stack) { $this->docker->deployStack($stack->endpoint, $stack->name, $stack->compose_content, $stack->env_vars ?? []); return back()->with('success', 'Stack deployed.'); } }