@include('admin.header')

<body class="skin-blue layout-top-nav">
<div class="wrapper">

@include('admin.sidebar')

<!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <div class="container inner_container">

            <!-- Main content -->
            <section class="content" style="padding: 20px 0;">

                <div class="box">

                    <div class="box-header with-border">
                        <h3 class="box-title">Post List</h3>
                    </div>

                    <?php

                    if(isset($_GET['save']) && $_GET['save'] == 'true'){

                    ?>

                    <div class="text-center">
                        <div style="display: inline-block;margin-top: 15px;" class=" alert alert-success">
                            <a style=" margin-left: 10px;text-decoration: none !important;" href="#" class="close"
                               data-dismiss="alert" aria-label="close">&times;</a>
                            <strong>Success!</strong> Post is successfully saved.
                        </div>
                    </div>

                <?php

                }

                ?>

                <!-- /.box-header -->
                    <div class="box-body">

                        <a style="margin: 10px 0;" href="{{url('admin/post/save')}}" class="btn btn-primary">Add new
                            post</a>

                        <div class="table_wrapper">
                            <table class="table table-bordered med_table">
                                <thead>
                                <tr>
                                    <th style="width: 200px;">Media</th>
                                    <th style="width: 200px;">Title</th>
                                    <th style="width: 100px;text-align: center;">Description</th>
                                    <th style="width: 100px;text-align: center;">Actions</th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php

                                if(isset($posts['data'])){

                                foreach($posts['data'] as $post){

                                ?>
                                <tr class="post-section">

                                    <td><img style="border: 1px solid #ddd;border-radius: 4px;padding: 5px;width: 150px;" src="{{\Illuminate\Support\Facades\URL::to('/') .'/images/'.$post['media']}}" /></td>
                                    <td><?php echo $post['title']; ?></td>
                                    <td style="text-align: center;"><?php echo $post['description']; ?></td>
                                    <td style="text-align: center;">
                                        <a href="{{url('admin/post/save/'.$post['id'])}}" class="edit_list">Edit</a>
                                        <span>|</span>
                                        <a href="" data-id="<?php echo $post['id']?>" class="delete_post">delete</a>
                                    </td>
                                </tr>

                                <?php

                                }


                                if(sizeof($posts['data']) == 0){

                                ?>
                                <tr>
                                    <td colspan="5" class="text-center">

                                        <p>No post found.</p>

                                    </td>
                                </tr>
                                <?php
                                }


                                }

                                ?>

                                </tbody>

                            </table>
                        </div>


                    </div>

                    <div class="col-md-6">

                        <?php
                        if(isset($posts['prev_page_url']) && $posts['prev_page_url']){
                        ?>
                        <a href="{{$posts['prev_page_url']}}" class="btn btn-primary">Previous</a>
                        <?php
                        }

                        ?>

                        <?php
                        if(isset($posts['next_page_url']) && $posts['next_page_url']){
                        ?>
                        <a href="{{$posts['next_page_url']}}" class="btn btn-primary">Next</a>
                        <?php
                        }

                        ?>

                    </div>

                    </ul>
                </div>

        </div>

        </section>
        <!-- /.content -->
    </div>

</div>


</div>

@include('admin.footer')
