第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從數(shù)據(jù)庫中檢索單字段數(shù)組數(shù)據(jù)并將它們分開 - 使用 laravel、PHP

如何從數(shù)據(jù)庫中檢索單字段數(shù)組數(shù)據(jù)并將它們分開 - 使用 laravel、PHP

PHP
慕容708150 2023-10-15 16:33:03
我嘗試為我的產(chǎn)品上傳多個圖像,并將該圖像的名稱作為數(shù)組存儲在數(shù)據(jù)庫中。我的代碼是這樣工作的 -$images = $request->file('images');      if (isset($images)) {  foreach($images as $image){    $imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();    if (!file_exists('uploads/product/images')) {       mkdir('uploads/product/images', 0777, true);    }      $image->move('uploads/product/images', $imagename);      $data[] = $imagename;    }              }else{     $data[] = 'default.png';  }  $product = new Product();  $product->images = json_encode($data);以及存儲在字段內(nèi)的數(shù)據(jù),images例如-["jeans-2020-08-13-5f352f18b30a4.jpg","jeans-2020-08-13-5f352f18b36a0.jpg","jeans-2020-08-13-5f352f18b3a2c.jpg"]**問題是我如何分離這個圖像名稱以在 Laravel Blade 中顯示圖像?**或者建議我,如果有其他方法可以在 laravel-6 中上傳多個圖像或多個值
查看完整描述

1 回答

?
慕田峪9158850

TA貢獻1794條經(jīng)驗 獲得超8個贊

您需要反序列化圖像名稱,然后循環(huán)它們:


@foreach(json_decode($product->images) ?? [] as $image)

    <img src="uploads/product/images/{{ $image }}">

@endforeach


查看完整回答
反對 回復 2023-10-15
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號