Skip to content

Instantly share code, notes, and snippets.

@rizkhal
Created February 22, 2020 08:18
Show Gist options
  • Save rizkhal/10504b3863321bd826bd38d32e7b13a4 to your computer and use it in GitHub Desktop.
Save rizkhal/10504b3863321bd826bd38d32e7b13a4 to your computer and use it in GitHub Desktop.
@extends('layouts.master')
@push('heading')
@component('components.heading')
All Posts
@endcomponent
@endpush
@push('button')
@component('components.button')
@slot('url')
{{ route('posts.create') }}
@endslot
@slot('text')
New Post
@endslot
@endcomponent
@endpush
@section('body')
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col">Body</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@if (count($posts) > 0)
@foreach ($posts as $key => $post)
<tr>
<th scope="row">{{$posts->firstItem() + $key}}</th>
<td>{{Str::limit($post->title, 20)}}</td>
<td>{{Str::limit($post->body, 20)}}</td>
<td>
<a href="{{ route('posts.edit', $post->slug) }}" class="btn btn-sm btn-warning">
<i class="fas fa-edit"></i>
</a>
<a href="{{ route('posts.destroy', $post->slug) }}" class="btn btn-sm btn-danger">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
@endforeach
@else
<tr>
<th colspan="4" class="text-center">Not Found</th>
</tr>
@endif
</tbody>
</table>
{{$posts->links()}}
@endsection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment