42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\RegistryType;
|
|
use App\Http\Requests\StoreRegistryRequest;
|
|
use App\Models\Organisation;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Response;
|
|
|
|
class RegistryController extends Controller
|
|
{
|
|
public function create(Request $request): Response
|
|
{
|
|
Organisation::findOrFail($request->route('organisation'));
|
|
|
|
return inertia('registries/Create', [
|
|
'registryTypes' => array_values(RegistryType::toArray()),
|
|
]);
|
|
}
|
|
|
|
public function store(StoreRegistryRequest $request): RedirectResponse
|
|
{
|
|
$organisation = Organisation::findOrFail($request->route('organisation'));
|
|
|
|
$organisation->registries()->create([
|
|
'name' => $request->string('name')->toString(),
|
|
'type' => $request->enum('type', RegistryType::class),
|
|
'url' => rtrim($request->string('url')->toString(), '/'),
|
|
'credentials' => [
|
|
'username' => $request->string('username')->toString(),
|
|
'password' => $request->string('password')->toString(),
|
|
],
|
|
]);
|
|
|
|
return redirect()
|
|
->route('organisations.show', ['organisation' => $organisation->id])
|
|
->with('success', 'Registry created.');
|
|
}
|
|
}
|