This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers\Api\V1\Product\Barcode;
use App\Http\Controllers\Api\V1\Product\Barcode\Requests\ProductBarcodeSearchIndexRequest;
use App\Http\Controllers\Controller;
use App\Models\Ecommerce\Product\Product\Product;
use Illuminate\Http\JsonResponse;
class ProductBarcodeSearchController extends Controller
{
/**
* Search product via barcode
*/
public function index(ProductBarcodeSearchIndexRequest $request): JsonResponse
{
$product = Product::where('barcode', $request->barcode)->with('media')->first();
return response()->rest([
'id' => $product->id,
'name' => $product->name,
'stock' => $product->stock,
'price_amount' => $product->price_amount,
'image' => [
'thumbnail' => $product->thumbnail(),
'images_400x400' => $product->getMedia('uploads')->map(fn ($media) => $media->getUrl('thumb400x400')),
'images_720x720' => $product->getMedia('uploads')->map(fn ($media) => $media->getUrl('thumb720x720')),
'images_800x800' => $product->getMedia('uploads')->map(fn ($media) => $media->getUrl('thumb800x800')),
'images_1200x1200' => $product->getMedia('uploads')->map(fn ($media) => $media->getUrl('thumb1200x1200')),
],
]);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Api\V1\Product\Barcode\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ProductBarcodeSearchIndexRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'barcode' => ['required', 'string', 'max:255', 'exists:products,barcode'],
];
}
}