Initial commit
This commit is contained in:
40
app/Http/Controllers/Api/SizeController.php
Normal file
40
app/Http/Controllers/Api/SizeController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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,
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user