* Product catalogue * Product categories * Physical, digital, service, and bundle product types * Product variants and option storage * SKU management * Product publishing states * Pricing and comparison pricing * Inventory quantities * Low-stock thresholds * Inventory movement history * Customer records and addresses * Orders and order items * Payment and fulfilment statuses * Payment transaction storage * Promotions and coupon codes * Shipping methods * Tax rates * Payment, shipping, tax, and inventory provider contracts * Default manual payment provider * Default flat-rate shipping provider * Public product REST API * Administration navigation * Commerce permissions * Module registration * Module boot tests
11 lines
638 B
PHP
11 lines
638 B
PHP
<?php
|
|
namespace Modules\Commerce\Http\Controllers;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Modules\Commerce\Models\Product;
|
|
final class ProductApiController extends Controller
|
|
{
|
|
public function index(): JsonResponse { return response()->json(Product::query()->where('status','active')->where(fn($q)=>$q->whereNull('published_at')->orWhere('published_at','<=',now()))->latest()->paginate(24)); }
|
|
public function show(string $product): JsonResponse { return response()->json(Product::where('status','active')->where(fn($q)=>$q->where('slug',$product)->orWhere('id',$product))->firstOrFail()); }
|
|
}
|