kabiri
4 months ago
312
1
Laravel

how can show photo in blade from database

Posted 4 months ago by kabiri

Hello . I have a product with multiple photo that saved by json.

public function store(ProductRequest $request)
    {
        if($request->hasfile('filename'))
         {

            foreach($request->file('filename') as $image)
            {
                $name=$image->getClientOriginalName();
                $year = Carbon::now()->year;
                $month = Carbon::now()->month;
                $day = Carbon::now()->day;
                $imagePath = "/upload/images/{$year}/{$month}/{$day}";
                $image->move(public_path($imagePath), $name);  
                $data[] = $name;  
            }
         }
      
        product::create(array_merge($request->all() , ['images' => json_encode($data)]));
        $request->session()->flash('success', '!محصول با موفقیت ثبت شد');
        return redirect(route('Products.index'));
    }

And my product saved sutch this:

0	
id	15
name	"میزی"
code	"۲۰۳۰"
price	"۲۰۰۰۰۰۰"
slug	"میزی"
description	null
images	"[\"carpet4-1.jpg\",\"index222.jpg\"]"
tags	"فرش ایرانی"
specialSail	0
specialPrice	null
size_id	5
color_id	4
discount_id	7
yarn_id	1
category_id	9
density_id	4
comb_id	4
created_at	"2020-06-15T09:55:18.000000Z"
updated_at	"2020-06-15T09:55:18.000000Z"

How can I show all photo for this product in blade?

Please sign in or create an account to participate in this conversation.