Implement Keystone environment deployments
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
use Tighten\Ziggy\Ziggy;
|
||||
@@ -29,8 +30,12 @@ class HandleInertiaRequests extends Middleware
|
||||
return [
|
||||
...parent::share($request),
|
||||
'name' => config('app.name'),
|
||||
'organisation' => $request->route('organisation') ? Organisation::with('applications')->findOrFail($request->route('organisation')) : null,
|
||||
'application' => $request->route('application') ? Application::with('environments')->findOrFail($request->route('application')) : null,
|
||||
'organisation' => $request->route('organisation')
|
||||
? Organisation::with('applications')->findOrFail($this->routeKey($request->route('organisation')))
|
||||
: null,
|
||||
'application' => $request->route('application')
|
||||
? Application::with('environments')->findOrFail($this->routeKey($request->route('application')))
|
||||
: null,
|
||||
'flash' => [
|
||||
'server_credentials' => $request->session()->has('sudo_password') ? [
|
||||
'sudo_password' => $request->session()->get('sudo_password'),
|
||||
@@ -45,4 +50,9 @@ class HandleInertiaRequests extends Middleware
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function routeKey(mixed $routeValue): mixed
|
||||
{
|
||||
return $routeValue instanceof Model ? $routeValue->getKey() : $routeValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user