Loyd
2 months ago
806
22
Laravel

Display string data in blade blade loop

Posted 2 months ago by Loyd

How to display the bellow image string in a blade I only want the basename

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" => "27"
    "user_id" => "1"
    "caption" => "bbbbbb"
    "location" => "nnnnn"
    "image" => "[{"encoded":"","mime":"image\/jpeg","dirname":"E:\Eventgram\public\storage\/uploads\/posts","basename":"yZPNg510RWLNSJJ1Qy6ppzucJuLg68lnoFUHsU3q.jpeg","extension":"jpeg","filename":"yZPNg510RWLNSJJ1Qy6ppzucJuLg68lnoFUHsU3q"},{"encoded":"","mime":"image\/png","dirname":"E:\Eventgram\public\storage\/uploads\/posts","basename":"2WUej5sQ57gLRsRF60xQlyubPrDW6diUD1Np8vmf.png","extension":"png","filename":"2WUej5sQ57gLRsRF60xQlyubPrDW6diUD1Np8vmf"},{"encoded":"","mime":"image\/png","dirname":"E:\Eventgram\public\storage\/uploads\/posts","basename":"TBw5xaXR661LC7HtIfN382NxttUpOQVicWcXGC95.png","extension":"png","filename":"TBw5xaXR661LC7HtIfN382NxttUpOQVicWcXGC95"}] ◀"
    "slug" => "bbbbbb"
    "created_at" => "2020-08-02 15:50:14"
    "updated_at" => "2020-08-02 15:50:14"
  ]
  #original: array:8 [▶]
  #changes: []
  #casts: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:1 [▶]
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

my blade

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

error

ErrorException 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.