add projet

This commit is contained in:
root
2026-03-05 12:29:37 -05:00
parent 8d1eef8ba8
commit 23b7db1107
9109 changed files with 1106501 additions and 73 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\User;
use Symfony\Component\HttpFoundation\Response;
class FrontendController extends BaseApiController
{
public function getUser()
{
$user = $this->getCurrentUser();
if (!$user) {
return $this->respondError('Authentication required', Response::HTTP_UNAUTHORIZED);
}
try {
$user = model(User::class);
$userInfo = $user->getUserInfoById($user->id);
if (!$userInfo) {
return $this->respondError('User not found', Response::HTTP_NOT_FOUND);
}
$firstname = (string) ($userInfo['firstname'] ?? '');
$lastname = (string) ($userInfo['lastname'] ?? '');
return $this->success([
'firstname' => $firstname,
'lastname' => $lastname,
'fullname' => trim($firstname . ' ' . $lastname),
'initials' => strtoupper(($firstname[0] ?? '') . ($lastname[0] ?? '')),
], 'User info retrieved successfully');
} catch (\Throwable $e) {
log_message('error', 'Frontend user error: ' . $e->getMessage());
return $this->respondError('Failed to retrieve user info', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getPages()
{
try {
return $this->success([
'pages' => [
'facility' => '/facility',
'team' => '/team',
'call_to_action' => '/call_to_action',
'testimonial' => '/testimonial',
],
], 'Frontend pages retrieved successfully');
} catch (\Throwable $e) {
log_message('error', 'Frontend pages error: ' . $e->getMessage());
return $this->respondError('Failed to retrieve frontend pages', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}