dimanche 25 avril 2021

Display Multiple Images in Laravel Datatables

I am trying many times to show multiple images in datatables, but it always failed. It's only display single image.

Images in database

[{"name":"_MG_2288 (1).jpg","path":"public\/product_images\/\/mKBWAFw7ZYgVqvz1lrxrEA5PYbal1EqqKm9jEx0F.jpg"},{"name":"555dca050423bda8418b4567.jpeg","path":"public\/product_images\/\/QnYnO9SfA9JJIu7wm0rxJOIJog6txmED8pdiZ4nM.jpg"}]

Controller

$data = \App\Product::latest()->get();

        return Datatables::of($data)
            ->addIndexColumn()
            ->addColumn('photo', function ($product) {
                foreach (json_decode($product->product_photo) as $picture) {
                    $pict = '<img src="/reference/eureka/storage/app/' . $picture->path . '" style="height:120px; width:200px"/>';
                    return $pict;
                }
            })
            ->rawColumns(['photo'])
            ->make(true);


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3xoD967
via IFTTT

Aucun commentaire:

Enregistrer un commentaire