1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-02-24 19:22:35 +01:00

Add some statistics to the dashboard

This commit is contained in:
Kovah 2019-04-24 21:53:33 +02:00
parent a9b4627b53
commit ecfe01afbb
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
3 changed files with 73 additions and 18 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,10 @@
<?php
return [
'stats' => 'Statistics',
'total_links' => 'Total Links',
'total_categories' => 'Total Categories',
'total_tags' => 'Total Tags',
];

View File

@ -40,23 +40,59 @@
</div>
</div>
<div class="card mt-4">
<div class="card-header">
@lang('link.recent_links')
</div>
<div class="row">
<div class="col-12 col-md-7">
<ul class="list-group list-group-flush">
@forelse($recent_links as $link)
<a href="{{ route('links.show', [$link->id]) }}" class="list-group-item list-group-item-action">
{!! $link->getIcon('mr-1') !!}
{{ $link->title }}
</a>
@empty
<li class="list-group-item text-danger">
@lang('linkace.no_results_found', ['model' => trans('link.links')])
</li>
@endforelse
</ul>
<div class="card mt-4">
<div class="card-header">
@lang('link.recent_links')
</div>
<ul class="list-group list-group-flush">
@forelse($recent_links as $link)
<a href="{{ route('links.show', [$link->id]) }}" class="list-group-item list-group-item-action">
{!! $link->getIcon('mr-1') !!}
{{ $link->title }}
</a>
@empty
<li class="list-group-item text-danger">
@lang('linkace.no_results_found', ['model' => trans('link.links')])
</li>
@endforelse
</ul>
</div>
</div>
<div class="col-12 col-md-5">
<div class="card mt-4">
<div class="card-header">
@lang('stats.stats')
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="d-flex align-items-center">
<span class="mr-1">@lang('stats.total_links')</span>
<span class="badge badge-secondary ml-auto">{{ $stats['total_links'] }}</span>
</div>
</li>
<li class="list-group-item">
<div class="d-flex align-items-center">
<span class="mr-1">@lang('stats.total_categories')</span>
<span class="badge badge-secondary ml-auto">{{ $stats['total_categories'] }}</span>
</div>
</li>
<li class="list-group-item">
<div class="d-flex align-items-center">
<span class="mr-1">@lang('stats.total_tags')</span>
<span class="badge badge-secondary ml-auto">{{ $stats['total_tags'] }}</span>
</div>
</li>
</ul>
</div>
</div>
</div>
@endsection