Changes to documents able to edit them now, also support for auto mail attechemnts

This commit is contained in:
Simon Pocrnjič
2025-10-18 19:04:10 +02:00
parent 761799bdbe
commit 3b1a24287a
19 changed files with 820 additions and 108 deletions
@@ -8,20 +8,21 @@
use App\Models\Document;
use App\Models\DocumentTemplate;
use App\Services\Documents\TokenValueResolver;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\RedirectResponse;
class ContractDocumentGenerationController extends Controller
{
public function __invoke(Request $request, Contract $contract): Response|RedirectResponse
{
// Inertia requests include the X-Inertia header and should receive redirects or Inertia responses, not JSON
$isInertia = (bool) $request->header('X-Inertia');
$wantsJson = ! $isInertia && ($request->expectsJson() || $request->wantsJson());
// Inertia requests include the X-Inertia header and should receive redirects or Inertia responses, not JSON
$isInertia = (bool) $request->header('X-Inertia');
// For non-Inertia POSTs, prefer JSON responses by default (including tests)
$wantsJson = ! $isInertia;
if (Gate::denies('read')) { // baseline read permission required to generate
abort(403);
}