feat: complete administration and reporting
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Domain\Administration\Services\NotificationTemplateService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class NotificationTemplateController extends Controller
|
||||
{
|
||||
public function edit(NotificationTemplateService $service): Response
|
||||
{
|
||||
return Inertia::render('admin/notification-templates', [
|
||||
'definitions' => $service->definitions(),
|
||||
'templates' => $service->templates(),
|
||||
'variables' => ['{reference}', '{requester}', '{starts_at}', '{ends_at}', '{comment}'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, NotificationTemplateService $service): RedirectResponse
|
||||
{
|
||||
$rules = [];
|
||||
foreach (array_keys($service->definitions()) as $event) {
|
||||
$rules["templates.{$event}.subject"] = ['required', 'string', 'max:200'];
|
||||
$rules["templates.{$event}.message"] = ['required', 'string', 'max:2000'];
|
||||
}
|
||||
/** @var array{templates:array<string,array{subject:string,message:string}>} $data */
|
||||
$data = $request->validate($rules);
|
||||
$service->update($data['templates'], $request->user());
|
||||
|
||||
return back()->with('success', 'Modelos de notificação atualizados.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user