• 1000 1006 *
public function edit(Product $product)
{
$categories = Category::get();
$main_image = $product->images()->where('main_image', 1)->first();
if ($main_image) {
$image = [];
$this->ShowMainImage($main_image, $image);
}
$other_images = $product->images()->where('main_image', 0)->get();
if ($other_images) {
$images = [];
$this->ShowOtherImages($other_images,$images);
}
return view('merchant.product.update',compact(
'product',
'categories',
'image',
'images'
));
}
МОЯ черта:
trait ProductTrait{
public function ShowMainImage($main_image,$image)
{
$image[] = [
"name" => $main_image->image,
"type" => \FileUploader::mime_content_type($main_image->image_path),
"size" => filesize('uploads/product_images/' . $main_image['image']),
"file" => $main_image->image_path,
"local" => $main_image->image_path,
'data' => [
"id" => $main_image->id,
],
];
}
public function ShowOtherImages($other_images,$images)
{
foreach ($other_images as $image) {
$images[] = [
"name" => $image->image,
"type" => \FileUploader::mime_content_type($image->image_path),
"size" => filesize('uploads/product_images/' . $image['image']),
"file" => $image->image_path,
"local" => $image->image_path,
'data' => [
"id" => $image->id,
],
];
}
}
}
Первое, что было раньше, работает, а второе - нет! проблема с массивами $image
и $images
Как я могу отправить пустой массив в черту и пересчитать массив с данными