update controllers logic

This commit is contained in:
root
2026-04-23 00:04:35 -04:00
parent 1977a513df
commit ca4ba272fc
353 changed files with 13402 additions and 1301 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Services\Docs;
use App\Models\User;
use App\Services\ApplicationUrlService;
class ApiDocsService
{
public function __construct(
private ApplicationUrlService $urls,
) {
}
/**
* Bootstrap payload for the documentation SPA (replaces CI swagger_ui / swagger_ui_public views).
*
* @return array<string, mixed>
*/
public function bootstrap(?User $user, bool $public): array
{
return [
'variant' => $public ? 'public' : 'full',
'title' => $public
? 'Al Rahma API — Public Docs'
: 'Al Rahma Sunday School — API Docs',
'openapi_url' => $this->urls->docsSwaggerMergedJsonUrl(false),
'try_it_out_enabled' => ! $public,
'persist_authorization' => ! $public,
'show_authorize_button' => ! $public,
'welcome_name' => $public ? null : $this->welcomeName($user),
];
}
private function welcomeName(?User $user): ?string
{
if (! $user) {
return null;
}
$full = trim(($user->firstname ?? '').' '.($user->lastname ?? ''));
return $full !== '' ? $full : ($user->email ?: 'Admin');
}
}