Skip to content

Commit

Permalink
Decrease database calls on contents
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Aug 27, 2024
1 parent c3c398e commit 35cd5e9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 9 deletions.
2 changes: 0 additions & 2 deletions app/Controllers/BlogpostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public function index(Request $request)
return response()->json($blogposts);
}


$this->view->title(trans('blogpost.blogposts'));
return $this->view->render('blogposts/index', [
'number_of_blogposts' => Blogpost::count(),
'all_blogposts' => $blogposts,
]);
}
Expand Down
1 change: 0 additions & 1 deletion app/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function index(Request $request)

$this->view->title(trans('page.pages'));
return $this->view->render('pages/index', [
'number_of_pages' => Page::count(),
'all_pages' => $pages,
'visible_pages' => Page::where('visibility', 1)->count(),
'home_page' => Page::find($this->request->settings['home_page']),
Expand Down
1 change: 0 additions & 1 deletion app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function index()

$this->view->title(trans('user.users'));
return $this->view->render('users/index', [
'number_of_users' => User::count(),
'all_users' => User::paginate($this->itemPerPage),
'active_users' => User::where('active', 1)->count(),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/View/blogposts/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@include('breadcrumb', [
'links' => [['name' => 'Content'], ['name' => 'Blog', 'url' => route('blogpost.index')]],
'page_title' => trans('blogpost.blogposts'),
'stats' => [['label' => trans('blogpost.all'), 'value' => $all_blogposts->count()]],
'stats' => [['label' => trans('blogpost.all'), 'value' => $all_blogposts->total()]],
'buttons' => [
[
'label' => trans('blogpost.new_post_button'),
Expand Down
4 changes: 2 additions & 2 deletions app/View/pages/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@include('breadcrumb', [
'links' => [['name' => 'Content'], ['name' => trans('page.pages'), 'url' => route('page.index')]],
'page_title' => trans('page.pages'),
'stats' => [['label' => trans('page.all'), 'value' => $number_of_pages],
'stats' => [['label' => trans('page.all'), 'value' => $all_pages->total()],
['label' => trans('page.visible'), 'value' => $visible_pages],
['label' => trans('page.invisible'), 'value' => $number_of_pages - $visible_pages]],
['label' => trans('page.invisible'), 'value' => $all_pages->total() - $visible_pages]],
'buttons' => [
[
'label' => trans('page.create_page_button'),
Expand Down
5 changes: 3 additions & 2 deletions app/View/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
'links' => [['name' => 'Content'], ['name' => trans('user.users'), 'url' => route('user.index')]],
'page_title' => trans('user.registered_users'),
'stats' => [
['label'=> trans('user.all'), 'value'=> $number_of_users],
['label'=> trans('user.all'), 'value'=> $all_users->total()],
['label'=> trans('user.active'), 'value'=> $active_users],
['label'=> trans('user.inactive'), 'value'=> $number_of_users - $active_users]
['label'=> trans('user.inactive'), 'value'=> $all_users->total() - $active_users]
],
'buttons' => [
[
Expand Down Expand Up @@ -133,4 +133,5 @@ class="dropdown-item text-danger text-decoration-none"


</div>
</div>
@endsection

0 comments on commit 35cd5e9

Please sign in to comment.