加入分頁連結至文章列表
This commit is contained in:
parent
b87090658c
commit
40155a3944
@ -16,7 +16,7 @@ class PostController extends Controller
|
||||
$resource = $this->getResource($request);
|
||||
$modelClass = $this->getModelClass($resource);
|
||||
$repo = new PostRepository($modelClass);
|
||||
$posts = $repo->getPostsPager();
|
||||
$posts = $repo->getPostsPager(12);
|
||||
return view('post.index', [
|
||||
'posts' => $posts,
|
||||
'resource' => $resource
|
||||
|
||||
@ -2,22 +2,30 @@
|
||||
|
||||
@section('content-body')
|
||||
<div class="container">
|
||||
@foreach($posts as $post)
|
||||
<article>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php if($post->featureImage): ?>
|
||||
<div class="img-wrapper">
|
||||
<img src="{{ $post->featureImage->url }}" alt="{{ $post->featureImage->description }}" class="post-feature-image">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@foreach($posts as $post)
|
||||
<article>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php if($post->featureImage): ?>
|
||||
<div class="img-wrapper">
|
||||
<img src="{{ $post->featureImage->url }}" alt="{{ $post->featureImage->description }}" class="post-feature-image">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<h2 class="title"><a href="{{ route($resource . '.show', [$post->id]) }}">{{ $post->title }}</a></h2>
|
||||
<div class="excerpt">{{ $post->excerpt }}</div>
|
||||
<div class="date">{{ $post->created_at }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<h2 class="title"><a href="{{ route($resource . '.show', [$post->id]) }}">{{ $post->title }}</a></h2>
|
||||
<div class="excerpt">{{ $post->excerpt }}</div>
|
||||
<div class="date">{{ $post->created_at }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@endforeach
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{!! $posts->links() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Loading…
Reference in New Issue
Block a user