@extends('layouts.app')

@section('content')

<div class="container">

    <div class="row justify-content-center">
        <div class="col-md-8 main-area">
            <h1 style="text-align: center;">
                健康資訊
            </h1>
        </div>
    </div>
    <div style="height:20px;">&nbsp;</div>

    @php
        foreach ($dataRows as $row)
        {
            $img_memo = '';
            $img_src = '/assets/img/news-item-a01.jpg';
            $imgs = $row->photos;
            // $imgs = array_filter($row['photos'], function($v) {
            //        return $v['is_selected'] == true;
            //    });
            if (count($imgs) > 0) 
            {
                foreach($imgs as $img)
                {
                    //$img_memo = $img['comment'];
                    $img_src = URL::asset('/storage/'.$img['file_path']);
                    break;
                }
            }
    @endphp
            <div class="row justify-content-center">
                <div class="col-md-8 main-area">
                    
                    <h2><a id="{{ $row->id }}" href="#{{ $row->id }}" class="anchor-point">{{ $row->title }}</a></h2>
                    <h5>發佈時間 <time>{{ date('Y-m-d H:i', strtotime($row->post_at)) }}</time></h5>
                    <img src="{{ $img_src }}" alt="{{ $img_memo }}" width="100%" height="auto">
                    
                    <div class="reset-container">
                        {!! $row->body !!}
                    </div>
                </div>
            </div>
            <div style="height: 20px;">&nbsp;</div>
    @php
        }
    @endphp
</div>


@endsection
