wowowowowo
This commit is contained in:
49
app/Http/Controllers/ProviderController.php
Normal file
49
app/Http/Controllers/ProviderController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ProviderType;
|
||||
use App\Http\Requests\StoreProviderRequest;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class ProviderController extends Controller
|
||||
{
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
Organisation::findOrFail($request->route('organisation'));
|
||||
|
||||
return inertia('providers/Create', [
|
||||
'providerTypes' => array_values(ProviderType::toArray()),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(StoreProviderRequest $request): RedirectResponse
|
||||
{
|
||||
$organisation = Organisation::findOrFail($request->route('organisation'));
|
||||
|
||||
$organisation->providers()->create([
|
||||
'name' => $request->string('name')->toString(),
|
||||
'type' => $request->enum('type', ProviderType::class),
|
||||
'token' => $request->string('token')->toString(),
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('organisations.show', ['organisation' => $organisation->id])
|
||||
->with('success', 'Server provider created.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$organisation = Organisation::findOrFail($request->route('organisation'));
|
||||
$provider = $organisation->providers()->findOrFail($request->route('provider'));
|
||||
|
||||
$provider->delete();
|
||||
|
||||
return redirect()
|
||||
->route('organisations.show', ['organisation' => $organisation->id])
|
||||
->with('success', 'Server provider deleted.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user