Files
compras/app/Http/Controllers/ExpenseAllocationController.php
T
nala 7da8d6c87a
tests / ci (push) Canceled after 0s
commit compras2 2911
2026-11-29 10:48:22 +02:00

56 lines
2.1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\ExternalPayment;
use App\Models\User;
use App\Services\ExpenseAllocations;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Symfony\Component\HttpFoundation\Response;
final class ExpenseAllocationController extends Controller
{
public function commonShow(Request $request, int $allocation, ExpenseAllocations $service): Response
{
$actor = $request->user('web');
abort_unless($actor instanceof User, 403);
$request->validate(['page' => 'nullable|integer|min:1|max:1000000']);
Inertia::encryptHistory();
$response = Inertia::render('payments/expense-allocation', $service->workspace($actor, $allocation, 'common_allocation'))->toResponse($request);
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
return $response;
}
public function commonStore(Request $request, int $allocation, ExpenseAllocations $service): Response
{
$actor = $request->user('web');
abort_unless($actor instanceof User, 403);
$service->save($actor, $allocation, $request->all(), 'common_allocation');
return back()->with('success', 'Imputação da despesa por categoria preservada.');
}
public function show(Request $request, ExternalPayment $payment, ExpenseAllocations $service): Response
{
$actor = $request->user('web');
abort_unless($actor instanceof User, 403);
$request->validate(['page' => 'nullable|integer|min:1|max:1000000']);
Inertia::encryptHistory();
$response = Inertia::render('payments/expense-allocation', $service->workspace($actor, $payment->id))->toResponse($request);
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
return $response;
}
public function store(Request $request, ExternalPayment $payment, ExpenseAllocations $service): Response
{
$actor = $request->user('web');
abort_unless($actor instanceof User, 403);
$service->save($actor, $payment->id, $request->all());
return back()->with('success', 'Imputação da despesa por categoria preservada.');
}
}