41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Website;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Website\Service;
|
|
|
|
class ServiceController extends Controller
|
|
{
|
|
public function index($locale)
|
|
{
|
|
$services = Service::all();
|
|
|
|
$response = $services->map(function ($service) use ($locale) {
|
|
return [
|
|
'id' => $service->id,
|
|
'imageSrc' => $service->imageSrc,
|
|
'altText' => '',
|
|
'created_at' => $service->created_at,
|
|
'updated_at' => $service->updated_at,
|
|
'title' => $service->getTranslation('title', $locale),
|
|
'description' => $service->getTranslation('description', $locale),
|
|
];
|
|
});
|
|
|
|
return response()->json($response);
|
|
}
|
|
|
|
public function showTranslation($id, $locale)
|
|
{
|
|
$service = Service::findOrFail($id);
|
|
|
|
return response()->json([
|
|
'id' => $service->id,
|
|
'imageSrc' => $service->imageSrc,
|
|
'title' => $service->getTranslation('title', $locale),
|
|
'description' => $service->getTranslation('description', $locale),
|
|
]);
|
|
}
|
|
}
|