Skip to content

Commit

Permalink
tags overview : show only tagged items from my groups
Browse files Browse the repository at this point in the history
  • Loading branch information
philippejadin committed May 18, 2019
1 parent 8fcdaf2 commit 0146337
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions app/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TagController extends Controller

public function index(Request $request)
{
//$tags = Discussion::allTagModels();

$tagService = app(\Cviebrock\EloquentTaggable\Services\TagService::class);
$tags = $tagService->getAllTags();

Expand Down Expand Up @@ -61,10 +61,44 @@ public function index(Request $request)

public function show(Request $request, $tag)
{
$discussions = Discussion::withAllTags($tag)->get();
$files = File::withAllTags($tag)->get();
$users = User::withAllTags($tag)->get();
$actions = Action::withAllTags($tag)->get();


$groups = Auth::user()->groups()->pluck('groups.id');


$discussions = Discussion::whereHas('group', function($q) use ($groups) {
$q->whereIn('group_id', $groups);
})
->whereHas('tags', function($q) use ($tag) {
$q->where('normalized', $tag);
})
->get();

$files = File::whereHas('group', function($q) use ($groups) {
$q->whereIn('group_id', $groups);
})
->whereHas('tags', function($q) use ($tag) {
$q->where('normalized', $tag);
})
->get();

$actions = Action::whereHas('group', function($q) use ($groups) {
$q->whereIn('group_id', $groups);
})
->whereHas('tags', function($q) use ($tag) {
$q->where('normalized', $tag);
})
->get();

$users = User::whereHas('groups', function($q) use ($groups) {
$q->whereIn('group_id', $groups);
})
->whereHas('tags', function($q) use ($tag) {
$q->where('normalized', $tag);
})
->get();




return view('tags.show')
Expand Down

0 comments on commit 0146337

Please sign in to comment.