²é¿´/±à¼ ´úÂë
ÄÚÈÝ
@extends('layouts.admin') @section('title', 'Blog') @section('content') <div class="content-wrapper"> <div class="content-header"> <div class="container-fluid"> <div class="mb-2 row"> <div class="col-sm-12"> <h1 class="m-0 text-dark">Blog</h1> </div> <div class="col-sm-12"> <ol class="breadcrumb"> <li class="breadcrumb-item text-warning"> <a href="{{ url('/home') }}">Dashboard</a> </li> <li class="breadcrumb-item active">Blog</li> </ol> </div> </div> </div> </div> <section class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-body"> @if (count($errors) > 0) @foreach ($errors->all() as $error) <div class="alert alert-danger alert-dismissible fade show" role="alert"> <strong>{{ $error }}!</strong> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> @endforeach @endif <div class="mb-2"> <a href="{{ url('/posts/create') }}" class="btn btn-primary btn-sm"> Add Post </a> </div> <table class="table table-bordered" id="example1"> <thead> <th></th> <th>Featured Image</th> <th>Title</th> <th>Category</th> <th>Status</th> <th>Action</th> </thead> <tbody> @foreach ($posts as $post) <tr class="item" data-id="{{ $post->id }}" id="row-{{ $post->id }}"> <td></td> <td> <img style="max-height: 55px" src="assets/images/thumbs/{{ $post->featured_img }}" alt="{{ $post->title }}" srcset=""> </td> <td> <a class="text-muted" href=""> {{ $post->title }} </a> </td> <td>{{ $post->category->name }}</td> <td> <span class="badge badge-info">{{ $post->status }}</span> </td> <td> <div class="btn-group"> <button type="button" class="btn btn-outline-success">Action</button> <button type="button" class="btn btn-outline-success dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <span class="sr-only">Toggle Dropdown</span> </button> <div class="dropdown-menu" role="menu" style=""> <a class="dropdown-item" href="/post/{{ $post->slug }}/edit">Edit</a> <a data-id="{{ $post->id }}" class="dropdown-item delete-item" href="#">Move to trash</a> </div> </div> </td> </tr> @endforeach </tbody> </table> </div> </div> </div> </div> </div> </section> </div> @stop @section('js') <script> $('.delete-item').on('click', function() { let $id = $(this).data('id') Swal.fire({ title: 'Are you sure you want to delete post ?', icon: 'warning', showCloseButton: true, showCancelButton: true, focusConfirm: false, confirmButtonText: 'Delete', confirmButtonAriaLabel: 'Thumbs up, great!', cancelButtonText: 'Cancel', cancelButtonAriaLabel: 'Thumbs down' }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { $(`#row-${$id}`).fadeOut(); $.ajax({ method: 'GET', url: `/post/delete/${$id}`, success: function() {}, error: function(err) { Swal.fire('Changes are not saved', '', 'info') }, }) } }) }) </script> @stop