@extends('layouts.heading-page')

@section('title')
    Events -
@endsection

@section('seo_keywords')
@endsection

@section('seo_description')
@endsection

@section('css')
    <link href="assets/css/page.css" rel="stylesheet"/>
@endsection

@section('breadcrumbs')
    Event
@endsection

@section('page-main')
        <div class="content-wrap news-wrap">
            <div class="container">
                <div class="mb-5">
                    <h2 class="h2-title">Event</h2>
                    <!-- 訊息發佈 -->
                    <div class="news-post">
                    @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
                        <article class="post-minimal">
                            <div class="post-left">
                                <figure class="post-image">
                                    <img src="{{ $img_src }}" alt="{{ $img_memo }}">
                                </figure>
                            </div>
                            <div class="post-body">
                                <h2><a href="/events/detail/{{ $row->id }}">{{ $row->title }}</a></h2>
                                <div class="post-text">
                                    <p><span>Date: </span>{{ date('Y-m-d', strtotime($row->post_at)) }}</p>
                                    <p><span>Venue: </span>{{ $row->venue }}</p>
                                    <p><span>Contact Us: </span>{{ $row->contact }}</p>
                                </div>
                                <div class="more"><a href="/events/detail/{{ $row->id }}">More</a></div>
                            </div>
                        </article>
                    @php
                        }
                    @endphp       
                    </div>

                    <!-- 分頁 -->
                    <nav aria-label="Page navigation" class="page-ex2">
                        <ul class="pagination pagination-sm justify-content-center">
                            <li class="page-item">
                                <a class="page-link prev" href="?p={{ ($dataCurrentPage - 1) < 1 ? 1 : ($dataCurrentPage - 1) }}" aria-label="Previous">
                                    <span aria-hidden="true">«</span>
                                </a>
                            </li>
                            @php
                                for ($i = 1; $i < ($dataTotalCount / $dataPerPageItems + 1); $i++)
                                {
                            @endphp
                            <li class="page-item {{ $dataCurrentPage == $i ? 'active' : '' }}"><a class="page-link" href="?p={{ $i }}">{{ $i }}</a></li>
                            @php
                                }
                            @endphp
                            <li class="page-item">
                                <a class="page-link next" href="?p={{ ($dataCurrentPage + 1) > floor($dataTotalCount / $dataPerPageItems + 1) ? floor($dataTotalCount / $dataPerPageItems + 1) : ($dataCurrentPage + 1) }}" aria-label="Next">
                                    <span aria-hidden="true">»</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
@endsection

@section('script')
    <script type="text/javascript">
		
	</script>
@endsection