سلام. وقت بخیر
تو قسمت آپدیت کردن وقتی تصاویر جدید انتخاب میکنم این خطا رو میده
The thumbnail url field must be an image.
The thumbnail url field must be a file of type: png, jpg, jpeg.
The demo url field must be an image.
The demo url field must be a file of type: png, jpg, jpeg.
The source url field must be an image.
The source url field must be a file of type: png, jpg, jpeg.
کدهای متد uploadImages
try {
$basePath = 'products/' . $createdProduct->id . '/';
$sourceImageFullPath = null;
$data = [];
if (isset($validatedData['source_url'])) {
$sourceImageFullPath = $basePath . 'source_url' . '_' . $validatedData['source_url']->getClientOriginalName();
ImageUploader::upload($validatedData['source_url'], $sourceImageFullPath, 'local_storage');
$data += ['source_url' => $sourceImageFullPath];
}
if (isset($validatedData['thumbnail_url'])) {
$fullPath = $basePath . 'thumbnail_url' . '_' . $validatedData['thumbnail_url']->getClientOriginalName();
ImageUploader::upload($validatedData['thumbnail_url'], $basePath, 'public_storage');
$data += ['thumbnail_url' => $fullPath];
}
if (isset($validatedData['demo_url'])) {
$fullPath = $basePath . 'demo_url' . '_' . $validatedData['demo_url']->getClientOriginalName();
ImageUploader::upload($validatedData['demo_url'], $fullPath, 'public_storage');
$data += ['demo_url' => $fullPath];
}
$updatedProduct = $createdProduct->update($data);
if (!$updatedProduct)
throw new \Exception();
return back()->with('success', 'Product created');
} catch (\Exception $e) {
return back()->with('failed', $e->getMessage());
}
متد آپدیت
public function update(UpdateRequest $request, $product_id)
{
$validatedData = $request->validated();
$product = Product::find($product_id);
$product->update([
'title' => $validatedData['title'],
'category_id' => $validatedData['category_id'],
'price' => $validatedData['price'],
'description' => $validatedData['description'],
]);
return $this->uploadImages($product, $validatedData);
}
ممنون میشم یه بررسی کنید.