@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            @if (session('submitted'))
                <div class="alert alert-primary" role="alert">
                    {{ session('submitted') }}
                </div>
            @endif
            <div class="card">
                <div class="card-header">{{ __('Dashboard') }}</div>
                <div class="card-body">
                    {{ __('You are logged in!') }}
                </div>
            </div>
        </div>
    </div>
    @if ($data && $data['memes_pending'])
    <div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 grid-memes mt-3">
        @foreach ($data['memes_pending'] as $meme)
            <div class="col mb-4">
                <div class="card">
                    @if ($meme->image)
                        <img src="{{ url($meme->image) }}" class="card-img-top mx-auto d-block" alt="{{ $meme->title }} Meme">
                    @else
                        <img src="https://picsum.photos/200" class="card-img-top" alt="{{ $meme->title }} Meme">
                    @endif
                    <div class="card-body">
                        <h5 class="card-title">{{ $meme->title }}</h5>
                        <p class="card-text">{{ $meme->caption }}</p>
                        <p class="card-text"><a href="{{ url('meme/approve/' . $meme->id) }}">Approve</a> | <a href="{{ url('meme/destroy/' . $meme->id) }}">Delete</a></p>
                        <p class="card-text">By: <a href="{{ url('/user/' . $meme->user->id) }}">{{ $meme->user->name }}</a></p>
                        <p class="card-text">{{ $meme->created_at->diffForHumans() }}</p>
                    </div>
                </div>
            </div>
        @endforeach
    </div>
    @endif
</div>
@endsection
