mardi 6 novembre 2018

show article first image from database as cover image

i have the images field in Articles table and i will save all images into this field as array : images/image1.jpg,images/image2.jpg, ...

in my index page, i am getting all articles and show them in home page :

$articles = \App\Article::all();

i want to just load first image from every article as cover image and show that but the images field is string. what can i do?

       @foreach($articles as $article)
        <div class="article_wrapper">
            <div class="article_body">
                    @foreach($article->images as $image)
                        
                    @endforeach
            </div>
        </div>
      @endforeach



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire