findOrFail($request->route('organisation')); return inertia('applications/Index', [ 'applications' => $organisation->applications, ]); } public function create(Request $request): Response { Organisation::findOrFail($request->route('organisation')); return inertia('applications/Create'); } public function store(StoreApplicationRequest $request): RedirectResponse { $organisation = Organisation::findOrFail($request->route('organisation')); $application = $organisation->applications()->create([ 'name' => $request->string('name')->toString(), 'repository_url' => $request->string('repository_url')->toString(), 'repository_type' => RepositoryType::GIT, 'default_branch' => $request->string('default_branch')->toString(), ]); app(GenerateDeployKey::class)->execute($application); app(CreateLaravelEnvironment::class)->execute($application->refresh(), $request->string('environment_name')->toString()); return redirect() ->route('applications.show', ['organisation' => $organisation->id, 'application' => $application->id]) ->with('success', 'Application created. Add the deploy key to your repository before verifying access.'); } public function show(Request $request): Response { $id = $request->route('application'); $organisation = Organisation::findOrFail($request->route('organisation')); $application = Application::with([ 'environments.services.slices', 'environments.attachments.service', 'environments.variables', 'organisation', ])->whereBelongsTo($organisation)->findOrFail($id); return inertia('applications/Show', [ 'application' => $application, 'servers' => inertia()->optional(function () use ($application) { return $application ->organisation ?->servers() ->where('status', ServerStatus::ACTIVE) ->with('services') ->get() ?? []; }), ]); } public function verifyRepository(Request $request): RedirectResponse { $organisation = Organisation::findOrFail($request->route('organisation')); $application = $organisation->applications()->findOrFail($request->route('application')); if (! app(VerifyRepositoryAccess::class)->execute($application)) { return back()->with('error', 'Repository access could not be verified.'); } return back()->with('success', 'Repository access verified.'); } }