From ecfe01afbbbeebc9548631eba2c0ce79b4b74faf Mon Sep 17 00:00:00 2001 From: Kovah Date: Wed, 24 Apr 2019 21:53:33 +0200 Subject: [PATCH] Add some statistics to the dashboard --- .../Controllers/App/DashboardController.php | 13 +++- resources/lang/en/stats.php | 10 +++ resources/views/dashboard.blade.php | 68 ++++++++++++++----- 3 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 resources/lang/en/stats.php diff --git a/app/Http/Controllers/App/DashboardController.php b/app/Http/Controllers/App/DashboardController.php index 8f50a33c..1b5ce3aa 100644 --- a/app/Http/Controllers/App/DashboardController.php +++ b/app/Http/Controllers/App/DashboardController.php @@ -3,7 +3,9 @@ namespace App\Http\Controllers\App; use App\Http\Controllers\Controller; +use App\Models\Category; use App\Models\Link; +use App\Models\Tag; class DashboardController extends Controller { @@ -16,10 +18,17 @@ class DashboardController extends Controller { $recent_links = Link::byUser(auth()->user()->id) ->orderBy('created_at', 'DESC') - ->limit(10) + ->limit(5) ->get(); + $stats = [ + 'total_links' => Link::count(), + 'total_categories' => Category::count(), + 'total_tags' => Tag::count(), + ]; + return view('dashboard') - ->with('recent_links', $recent_links); + ->with('recent_links', $recent_links) + ->with('stats', $stats); } } diff --git a/resources/lang/en/stats.php b/resources/lang/en/stats.php new file mode 100644 index 00000000..f72356ae --- /dev/null +++ b/resources/lang/en/stats.php @@ -0,0 +1,10 @@ + 'Statistics', + 'total_links' => 'Total Links', + 'total_categories' => 'Total Categories', + 'total_tags' => 'Total Tags', + +]; diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 439740dd..7ae6bc20 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -40,23 +40,59 @@ -
-
- @lang('link.recent_links') -
+
+
- +
+
+ @lang('link.recent_links') +
+ + +
+ +
+
+ +
+
+ @lang('stats.stats') +
+ +
    +
  • +
    + @lang('stats.total_links') + {{ $stats['total_links'] }} +
    +
  • +
  • +
    + @lang('stats.total_categories') + {{ $stats['total_categories'] }} +
    +
  • +
  • +
    + @lang('stats.total_tags') + {{ $stats['total_tags'] }} +
    +
  • +
+
+ +
@endsection