diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index 633f5496fe..707fb39ffa 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -86,6 +86,7 @@ class ShowController extends Controller $end = $end ?? session('end', Carbon::now()->endOfMonth()); $subTitleIcon = 'fa-bar-chart'; $page = (int) $request->get('page'); + $attachments = $this->repository->getAttachments($category); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; $oldest = $this->repository->firstUseDate($category) ?? Carbon::now()->startOfYear(); $periods = $this->getCategoryPeriodOverview($category, $oldest, $end); @@ -107,7 +108,7 @@ class ShowController extends Controller //Log::debug('End of show()'); - return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', compact('category','attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } /** @@ -134,7 +135,7 @@ class ShowController extends Controller $start = $first ?? new Carbon; $end = new Carbon; $path = route('categories.show.all', [$category->id]); - + $attachments = $this->repository->getAttachments($category); /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); @@ -145,6 +146,6 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath($path); - return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', compact('category','attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } } diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 3cf609c37c..d3c9e0ad22 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -179,7 +179,7 @@ class CategoryRepository implements CategoryRepositoryInterface public function getCategories(): Collection { /** @var Collection $set */ - $set = $this->user->categories()->orderBy('name', 'ASC')->get(); + $set = $this->user->categories()->with(['attachments'])->orderBy('name', 'ASC')->get(); return $set; } diff --git a/resources/views/v1/categories/show.twig b/resources/views/v1/categories/show.twig index 669b5d21bc..f45efb3a51 100644 --- a/resources/views/v1/categories/show.twig +++ b/resources/views/v1/categories/show.twig @@ -8,7 +8,7 @@
{% if Route.getCurrentRoute.getName == 'categories.show' %} {# both charts #} -
+

@@ -20,7 +20,7 @@

-
+

@@ -35,7 +35,7 @@ {% endif %} {% if Route.getCurrentRoute.getName == 'categories.show.all' %} {# all chart #} -
+

@@ -48,6 +48,20 @@

{% endif %} + {% if attachments.count > 0 %} +
+
+
+

+ {{ 'attachments'|_ }} +

+
+
+ {% include 'list.attachments' %} +
+
+
+ {% endif %}
{% if periods|length > 0 %}
diff --git a/resources/views/v1/list/categories.twig b/resources/views/v1/list/categories.twig index 425008ca41..de31f39fc8 100644 --- a/resources/views/v1/list/categories.twig +++ b/resources/views/v1/list/categories.twig @@ -25,6 +25,9 @@ {{ category.name }} + {% if category.attachments.count > 0 %} + + {% endif %} {% if category.lastActivity %}