Merge branch 'trunk'

This commit is contained in:
Noah Lancien 2026-05-20 15:37:47 +02:00
commit fa1cbeb184
6 changed files with 48 additions and 5 deletions

View file

@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Company;
use Illuminate\Support\Str;
class CompanyController
{
/**
* Retrieve all published companies with their associated activity and sector.
*
* @return \Illuminate\Http\JsonResponse
*/
public function getCompanies(): \Illuminate\Http\JsonResponse
{
$companies = Company::query()->where('published', true)->with('companyActivity', 'companySector')->get();
$data = $companies->map(function ($company) {
return array_filter([
'name' => $company->name,
'logo' => $company->logo,
'informations' => $company->informations,
'responsable' => $company->responsable,
'employees' => $company->employees,
'url' => $company->url,
'latitude' => $company->latitude,
'longitude' => $company->longitude,
'type_activite' => Str::lower($company->companyActivity->name),
'filiere' => $company->companySector?->name,
], fn($value) => !is_null($value));
});
return response()->json($data);
}
}

View file

@ -14,6 +14,7 @@ return Application::configure(basePath: dirname(__DIR__))
__DIR__ . '/../routes/web-front.php',
__DIR__ . '/../routes/web-back.php',
],
api: __DIR__.'/../routes/api.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {

View file

@ -35,7 +35,7 @@ Zone géographique :
Société : {{ $data->company }}
@endif
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType) ||
@if (is_array($data->type) && \App\Enums\Contact\ContactFormType::restauration->equals($data->enumType) ||
\App\Enums\Contact\ContactFormType::export->equals($data->enumType))
Type de demande :
@foreach($data->type as $t)

View file

@ -50,7 +50,7 @@
<p>Société : {{ $data->company }}</p>
@endif
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType))
@if (is_array($data->type) && \App\Enums\Contact\ContactFormType::restauration->equals($data->enumType))
<p>Type de demande : </p>
<ul>
@foreach ($data->type as $t)
@ -60,7 +60,7 @@
@endif
{{-- Export --}}
@if (\App\Enums\Contact\ContactFormType::export->equals($data->enumType))
@if (is_array($data->type) && \App\Enums\Contact\ContactFormType::export->equals($data->enumType) && $data->type)
<p>Type de demande : </p>
<ul>
@foreach ($data->type as $t)

View file

@ -60,7 +60,7 @@
@endif
@if (isset($pageFinance))
<li id="menu-item-199" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-199">
<a href="{{ \App\Helpers\RouteHelper::routeNameChecker('front.finance') }}">{{ $pageFinance->title }}</a>
<a href="{{ \App\Helpers\RouteHelper::routeNameChecker('front.dynamic-pages.finance') }}">{{ $pageFinance->title }}</a>
</li>
@endif
@if (isset($pageNosMetiers))
@ -69,7 +69,7 @@
</li>
@endif
<li id="menu-item-6108" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-6108">
<a href="{{ LaravelLocalization::getLocalizedURL(app()->getLocale(), __('routes.contact_index')) }}">
<a href="{{ \App\Helpers\RouteHelper::routeNameChecker('front.dynamic-pages.nous-contacter') }}">
{{ ucfirst(__('front.contact.index')) }}
</a>
</li>

6
routes/api.php Normal file
View file

@ -0,0 +1,6 @@
<?php
use App\Http\Controllers\Api\CompanyController;
use Illuminate\Support\Facades\Route;
Route::get('/companies', [CompanyController::class, 'getCompanies']);