Skip to content

Commit

Permalink
Merge pull request #59 from nWidart/feature/update-latest-post-widget
Browse files Browse the repository at this point in the history
Feature/update latest post widget
  • Loading branch information
nWidart authored Oct 2, 2017
2 parents dd3c29f + 40b2040 commit 8decfe4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
'latest-posts' => [
'blog.*',
'blog::admin.widgets.latest-posts',
],

'post' => [
Expand Down
14 changes: 14 additions & 0 deletions Providers/BlogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function boot()

$this->registerThumbnails();
$this->app[TagManager::class]->registerNamespace(new Post());
$this->registerViewComposers();
}

/**
Expand Down Expand Up @@ -117,4 +118,17 @@ private function registerThumbnails()
],
]);
}

private function registerViewComposers()
{
$this->app['view']->composer(
config('asgard.blog.config.latest-posts', ['blog.*']),
\Modules\Blog\Composers\Frontend\LatestPostsComposer::class
);

$this->app['view']->composer([
'blog::admin.posts.create',
'blog::admin.posts.edit',
], \Modules\Core\Composers\CurrentUserViewComposer::class);
}
}
8 changes: 4 additions & 4 deletions Resources/views/admin/widgets/latest-posts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<th>{{ trans('blog::post.table.title') }}</th>
<th>{{ trans('core::core.table.created at') }}</th>
</tr>
<?php if (isset($posts)): ?>
<?php foreach ($posts as $post): ?>
@if (isset($latestPosts))
@foreach ($latestPosts as $post)
<tr>
<td>{{ $post->id }}</td>
<td>{{ $post->title }}</td>
<td>{{ $post->created_at }}</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@endforeach
@endif
</tbody>
</table>
</div><!-- /.box-body -->
Expand Down
2 changes: 1 addition & 1 deletion Widgets/LatestPostsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ protected function data()
{
$limit = $this->setting->get('blog::widget-posts-amount', locale(), 5);

return ['posts' => $this->post->latest($limit)];
return ['latestPosts' => $this->post->latest($limit)];
}
}
1 change: 1 addition & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ versions:
"3.0.0@unreleased":
changed:
- Tags are new set using the Tag module (BC)
- Allow the latest posts widget to be included on its own
"2.2.0":
changed:
- Register the blog sidebar via event handler
Expand Down
11 changes: 0 additions & 11 deletions composers.php

This file was deleted.

1 change: 0 additions & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"Modules\\Blog\\Widgets\\LatestPostsWidget"
],
"files": [
"composers.php"
]
}

0 comments on commit 8decfe4

Please sign in to comment.