@php
    $blogs = HelpDesk::elementPostsByArgs($args);
@endphp

<!-- Our Blog -->
<section class="default-el">
    <div class="container">
        @if (isset($args['subtitle']) || isset($args['title']) || isset($args['view_all']) || isset($args['page_id']))
        <div class="section-head">
            <div class="content">
                <p class="sub-title">{{ isset($args['subtitle']) ? $args['subtitle'] : '' }}</p>
                <h2 class="title">{{ isset($args['title']) ? $args['title'] : '' }}</h2>
                <p class="description">{{ isset($args['description']) ? $args['description'] : '' }}</p>
            </div>

            <div>
                @if (isset($args['view_all']) && $args['view_all'] == 'true')

                <a 
                    href="{{ isset($args['page_id']) ? DzHelper::laraPageLink($args['page_id']) : 'javascript:void(0);' }}"
                    class="btn btn-outline light style-1 ms-auto p-2 group button--stroke flairBtn magneticBtn" 
                    data-block="button"
                >
                    <span class="button-flair"></span>
                    <span class="button__label font-normal xl:ps-25 px-10 inline-flex items-center gap-14">{{ __('View All') }}</span>
                    <span class="inline-flex justify-center items-center size-32 rounded-full dark:bg-primary dark:text-secondary bg-secondary text-white duration-100 dark:group-hover:bg-secondary dark:group-hover:text-white group-hover:bg-white group-hover:text-secondary z-1">
                        <i class="fa-solid fa-arrow-right text-sm"></i>
                    </span>
                </a>
                @endif
            </div>
        </div>
        @endif
        <div class="row">
            @forelse($blogs as $blog)
            <div class="lg:w-8/12 w-full mb-40">
                <div class="dz-card default-el-1 blog-half overlay-shine mb-40 dark:!bg-card">
                    <div class="dz-media">
                        <a href="{{ DzHelper::laraBlogLink($blog->id) }}">
                            @if(optional($blog->feature_img)->value && Storage::exists('public/blog-images/'.$blog->feature_img->value))
                                <img src="{{ asset('storage/blog-images/'.$blog->feature_img->value) }}" alt="{{ __('Blog Image') }}">
                            @else
                                <img src="{{ asset('images/noimage.jpg') }}" alt="{{ __('Blog Image') }}">
                            @endif
                        </a>
                    </div>
                    <div class="dz-info">
                        <div class="dz-meta">
                            <ul>
                                <li class="post-author dark:text-white">
                                    <a href="javascript:void(0);">
                                        <img class="inline" src="{{ HelpDesk::user_img($blog->user->profile) }}" alt="">{{ $blog->user->name }}</a>
                                </li>
                                <li class="post-date dark:text-white"><a href="javascript:void(0);">  {{ Carbon\Carbon::parse($blog->publish_on)->format(config('Site.custom_date_format')) }}</a></li>
                                <li class="post-comment dark:text-white"><a href="javascript:void(0);">{{ $blog->blog_comments_count}} {{ __('comments') }}</a></li>
                            </ul>
                        </div>
                        <h4 class="dz-title"><a href="{{ DzHelper::laraBlogLink($blog->id) }}">{{ Str::limit($blog->title, 40, ' ...') }}</a></h4>
                        <p>{{ Str::limit($blog->excerpt, 80, ' ...') }}</p>
                        <a href="{{ DzHelper::laraBlogLink($blog->id) }}" class="read-more-btn bg-primary ">{{ __('Read More') }}</a>
                    </div>
                </div>
            </div>
            @empty
            @endforelse
            @if (isset($args['pagination']) && ($args['pagination'] == true))
            <div class="w-full ">
                {!! $blogs->links('elements.pagination') !!}
            </div>
            @endif
        </div>
    </div>
</section>
<!-- Our Blog -->



