Skip to content

Commit 6cf7600

Browse files
author
Kyle
committed
fix ordering of posts
1 parent bb41c5a commit 6cf7600

File tree

4 files changed

+50
-39
lines changed

4 files changed

+50
-39
lines changed

app/LetsBlog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LetsBlog
1212
{
1313
public static function published()
1414
{
15-
return Post::with('tags', 'series')->paginate(config('letsblog.posts.perpage'));
15+
return Post::with('tags', 'series')->orderBy('published_at', 'desc')->paginate(config('letsblog.posts.perpage'));
1616
}
1717

1818
public static function search($q = '')

config/letsblog.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
// 'admin_path' => 'admin',
1111
'admin_path' => 'false',
1212

13+
//enable admin section
14+
'admin' => 'false',
15+
1316
//default theme
1417
// 'theme' => 'letsblog::themes.default'
1518

resources/views/themes/extension/admin/posts/index.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<thead>
1515
<tr>
1616
<th>Title</th>
17-
<th>Published At</th>
18-
<th>Created At</th>
19-
<th>Updated At</th>
17+
<th>Published</th>
18+
<th>Created</th>
19+
<th>Updated</th>
2020
<th></th>
2121
</tr>
2222
</thead>
@@ -26,7 +26,7 @@
2626
<td><a href="/posts/{!! $p->slug !!}" target="_blank">{{ $p->title }}</a></td>
2727
<td>
2828
@if ( ! empty($p->published_at) AND $p->published_at->timestamp < strtotime('now'))
29-
<span style="color:darkgreen;">{{ $p->published_at->format('Y-m-d H:i:s') }}</span>
29+
<span style="color:darkgreen;">{{ $p->published_at->format('Y-m-d') }}</span>
3030
@elseif ( ! empty($p->published_at) AND $p->published_at->timestamp > strtotime('now'))
3131
<span style="color:darkblue;">{{ $p->published_at->format('Y-m-d H:i:s') }}</span>
3232
@else

resources/views/themes/extension/post/list.blade.php

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,49 @@
11
@section ('post.list')
22

3-
@forelse ($posts as $k => $p)
4-
5-
<div class="col-xs-12 col-sm-6 post-panel">
6-
<div class="panel panel-info">
7-
8-
<div class="panel-heading">
9-
<h1 class="panel-title">
10-
<a href="{{ $p->url }}">{{ $p->full_title }}</a>
11-
</h1>
3+
@forelse($posts->chunk(2) as $chunk)
4+
5+
<div class="row">
6+
@foreach($chunk as $p)
7+
8+
<div class="col-xs-12 col-sm-6 post-panel">
9+
<div class="panel panel-info">
10+
11+
<div class="panel-heading">
12+
<h1 class="panel-title">
13+
<a href="{{ $p->url }}">{{ $p->full_title }}</a>
14+
</h1>
15+
</div>
16+
17+
<div class="panel-body">
18+
@if( ! empty($p->meta->image))
19+
<a href="{{ $p->url }}">
20+
<img class="thumbnail" src="{{ $p->img }}" style="width:85%; margin:0px;"/>
21+
</a>
22+
@endif
23+
24+
<p>
25+
@foreach ($p->tags as $t)
26+
<a href="{{ $t->url }}" class="btn btn-xs btn-primary">{{ $t->name }}</a>
27+
@endforeach
28+
29+
@if ($p->series)
30+
<a href="{{ $p->series->url }}" class="btn btn-xs btn-warning">{{ $p->series->title }}</a>
31+
@endif
32+
</p>
33+
34+
<p>
35+
{{ $p->meta }}
36+
</p>
37+
38+
<div class="post-panel-footer"><a href="{{ $p->url }}">Read</a><span class="text-muted pull-right">{{ $p->published_at->format('Y-m-d') }}<span></div>
39+
40+
</div>
41+
</div>
42+
1243
</div>
1344

14-
<div class="panel-body">
15-
@if( ! empty($p->meta->image))
16-
<a href="{{ $p->url }}">
17-
<img class="thumbnail" src="{{ $p->img }}" style="width:85%; margin:0px;"/>
18-
</a>
19-
@endif
20-
21-
<p>
22-
@foreach ($p->tags as $t)
23-
<a href="{{ $t->url }}" class="btn btn-xs btn-primary">{{ $t->name }}</a>
24-
@endforeach
25-
26-
@if ($p->series)
27-
<a href="{{ $p->series->url }}" class="btn btn-xs btn-warning">{{ $p->series->title }}</a>
28-
@endif
29-
</p>
30-
31-
<p>
32-
{{ $p->meta }}
33-
</p>
34-
35-
<div class="post-panel-footer"><a href="{{ $p->url }}">Read</a><span class="text-muted pull-right">{{ $p->published_at->format('Y-m-d') }}<span></div>
36-
37-
</div>
38-
</div>
45+
@endforeach
46+
3947
</div>
4048

4149
@empty

0 commit comments

Comments
 (0)