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); } }