authorize('viewAny', [Command::class, $site, $server]); return Inertia::render('commands/index', [ 'commands' => CommandResource::collection($site->commands()->latest()->simplePaginate(config('web.pagination_size'))), ]); } #[Post('/', name: 'commands.store')] public function store(Request $request, Server $server, Site $site): RedirectResponse { $this->authorize('create', [Command::class, $site, $server]); app(CreateCommand::class)->create($site, $request->input()); return back() ->with('success', 'Command created successfully.'); } #[Get('/{command}', name: 'commands.show')] public function show(Server $server, Site $site, Command $command): Response { $this->authorize('view', [$command, $site, $server]); return Inertia::render('commands/show', [ 'command' => new CommandResource($command), 'executions' => CommandExecutionResource::collection($command->executions()->latest()->simplePaginate(config('web.pagination_size'))), ]); } #[Put('/{command}', name: 'commands.update')] public function update(Request $request, Server $server, Site $site, Command $command): RedirectResponse { $this->authorize('update', [$command, $site, $server]); app(EditCommand::class)->edit($command, $request->input()); return back() ->with('success', 'Command updated successfully.'); } #[Delete('/{command}', name: 'commands.destroy')] public function destroy(Server $server, Site $site, Command $command): RedirectResponse { $this->authorize('delete', [$command, $site, $server]); $command->delete(); return back() ->with('success', 'Command deleted successfully.'); } #[Post('/{command}/execute', name: 'commands.execute')] public function execute(Request $request, Server $server, Site $site, Command $command): RedirectResponse { $this->authorize('update', [$site, $server]); app(ExecuteCommand::class)->execute($command, user(), $request->input()); return redirect()->route('commands.show', ['server' => $server, 'site' => $site, 'command' => $command]) ->with('info', 'Command is being executed.'); } }