create image upload endpoint create product creation endpoint create get product categories endpoint
23 lines
431 B
PHP
23 lines
431 B
PHP
<?php
|
|
|
|
namespace App\Data;
|
|
|
|
use App\Models\Product;
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
readonly class UploadImageDTO
|
|
{
|
|
public function __construct(
|
|
public UploadedFile $image,
|
|
public Product $product,
|
|
) {}
|
|
|
|
public static function fromRequest(array $data): self
|
|
{
|
|
return new self(
|
|
image: $data['image'],
|
|
product: Product::find($data['product_id']),
|
|
);
|
|
}
|
|
}
|