Loyd
2 months ago
432
6
Laravel

Display string data in blade

Posted 2 months ago by Loyd

I have an image string in Post. My question is how do I display this array in a blade.

App\Post {#1308 ▼
  #fillable: array:5 [▶]
  +with: array:1 [▶]
  #connection: "sqlite"
  #table: "posts"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:8 [▼
    "id" => "24"
    "user_id" => "1"
    "caption" => "ntgjbjk"
    "location" => "kkk"
    "image" => "["uploads\/posts\/\/d2AW5jRNNBfWPq8EsHxbsqpMfFfdTZkBg0Jbc3iO.jpeg","uploads\/posts\/\/ROz8vckqID1YOleIdkwSFMm7oxJPuUR04VpcPiSL.png"]"
    "slug" => "ntgjbjk"
    "created_at" => "2020-08-02 14:18:54"
    "updated_at" => "2020-08-02 14:18:54"
  ]
  #original: array:8 [▶]
  #changes: []
  #casts: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:1 [▶]
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

what I have tried so far in my blade

 @foreach($post->image as $photo)
                                <li class="glide__slide">
                                    <img src="/storage/{{$photo}}" class="photo__file"/>
                                </li>
                            @endforeach

and getting this error Invalid argument supplied for foreach() (View: E:\Eventgram\resources\views\post\show.blade.php)

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