41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Models\Size;
|
|
|
|
class SizeController extends Controller
|
|
{
|
|
public function index(): JsonResponse
|
|
{
|
|
$size = Size::first();
|
|
|
|
if (!$size) {
|
|
return response()->json([
|
|
'status' => 'error',
|
|
'message' => 'Size configuration not found'
|
|
], 404);
|
|
}
|
|
|
|
return response()->json([
|
|
'status' => 'success',
|
|
'data' => [
|
|
'small' => [
|
|
'description' => $size->small,
|
|
'photo' => $size->small_photo ? '/storage/' . $size->small_photo : null,
|
|
],
|
|
'medium' => [
|
|
'description' => $size->medium,
|
|
'photo' => $size->medium_photo ? '/storage/' . $size->medium_photo : null,
|
|
],
|
|
'large' => [
|
|
'description' => $size->large,
|
|
'photo' => $size->large_photo ? '/storage/' . $size->large_photo : null,
|
|
],
|
|
]
|
|
]);
|
|
}
|
|
}
|