|
|
|
@ -4,6 +4,7 @@ use Movim\Widget\Base; |
|
|
|
|
|
|
|
use Respect\Validation\Validator; |
|
|
|
use App\Configuration; |
|
|
|
use Carbon\Carbon; |
|
|
|
|
|
|
|
include_once WIDGETS_PATH . 'Post/Post.php'; |
|
|
|
|
|
|
|
@ -28,11 +29,27 @@ class Communities extends Base |
|
|
|
->restrictNSFW() |
|
|
|
->recents() |
|
|
|
->orderBy('posts.published', 'desc') |
|
|
|
->where('open', true) |
|
|
|
->take(30) |
|
|
|
->get(); |
|
|
|
->where('open', true); |
|
|
|
|
|
|
|
$view->assign('posts', $posts); |
|
|
|
$postsIds = $posts->take(200)->pluck('id')->toArray(); |
|
|
|
|
|
|
|
$tags = \App\Tag::whereIn('id', function ($query) use ($postsIds) { |
|
|
|
$query->select('tag_id') |
|
|
|
->fromSub(function ($query) use ($postsIds) { |
|
|
|
$query->selectRaw('tag_id, count(tag_id) as count') |
|
|
|
->fromSub(function ($query) use ($postsIds) { |
|
|
|
$query->from('post_tag') |
|
|
|
->whereIn('post_id', $postsIds) |
|
|
|
->get(); |
|
|
|
}, 'last_month') |
|
|
|
->groupBy('tag_id') |
|
|
|
->orderBy('count', 'desc') |
|
|
|
->take(20); |
|
|
|
}, 'top'); |
|
|
|
})->get(); |
|
|
|
|
|
|
|
$view->assign('tags', $tags); |
|
|
|
$view->assign('posts', $posts->take(30)->get()); |
|
|
|
$view->assign('communities', $this->user->session->interestingCommunities() |
|
|
|
->take(6) |
|
|
|
->get()); |
|
|
|
|