36 lines
1021 B
PHP
36 lines
1021 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Actions\Applications\CreateInstance;
|
|
use App\Models\Application;
|
|
use App\Models\Server;
|
|
use Illuminate\Http\Request;
|
|
|
|
class InstanceController extends Controller
|
|
{
|
|
public function store(Request $request, Application $application)
|
|
{
|
|
$validated = $request->validate([
|
|
'server_id' => 'required|exists:servers,id',
|
|
'branch' => 'required|string|max:255',
|
|
'config' => 'sometimes|array',
|
|
]);
|
|
|
|
$server = Server::findOrFail($validated['server_id']);
|
|
|
|
$instance = (new CreateInstance())->execute(
|
|
$application,
|
|
$server,
|
|
$validated['branch'],
|
|
$validated['config'] ?? []
|
|
);
|
|
|
|
return redirect()
|
|
->route('applications.show', [
|
|
'organisation' => $application->organisation_id,
|
|
'application' => $application->id
|
|
])
|
|
->with('success', 'Instance created successfully');
|
|
}
|
|
} |