1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Xetaravel\Http\Controllers\Admin; |
6
|
|
|
|
7
|
|
|
use Illuminate\Contracts\View\Factory; |
8
|
|
|
use Illuminate\Contracts\View\View; |
9
|
|
|
use Illuminate\Foundation\Application; |
10
|
|
|
use Illuminate\Support\Facades\App; |
11
|
|
|
use Illuminate\Support\Facades\Cache; |
12
|
|
|
use Xetaravel\Http\Components\AnalyticsComponent; |
13
|
|
|
use Xetaravel\Models\BlogArticle; |
14
|
|
|
use Xetaravel\Models\BlogComment; |
15
|
|
|
use Xetaravel\Models\User; |
16
|
|
|
|
17
|
|
|
class PageController extends Controller |
18
|
|
|
{ |
19
|
|
|
use AnalyticsComponent; |
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Show the application dashboard. |
23
|
|
|
* |
24
|
|
|
* @return Factory|View|Application|\Illuminate\View\View|object |
25
|
|
|
*/ |
26
|
|
|
public function index() |
27
|
|
|
{ |
28
|
|
|
$minutes = config('analytics.cache_lifetime_in_minutes'); |
29
|
|
|
|
30
|
|
|
$viewDatas = []; |
31
|
|
|
|
32
|
|
|
if (!App::environment('testing')) { |
33
|
|
|
|
34
|
|
|
/*$visitorsData = Cache::remember('Analytics.visitors', $minutes, function () { |
35
|
|
|
return $this->buildVisitorsGraph(); |
36
|
|
|
}); |
37
|
|
|
$viewDatas[] = 'visitorsData'; |
38
|
|
|
|
39
|
|
|
$browsersData = Cache::remember('Analytics.browsers', $minutes, function () { |
40
|
|
|
return $this->buildBrowsersGraph(); |
41
|
|
|
}); |
42
|
|
|
$viewDatas[] = 'browsersData'; |
43
|
|
|
|
44
|
|
|
$devicesGraph = Cache::remember('Analytics.devices', $minutes, function () { |
45
|
|
|
return $this->buildDevicesGraph(); |
46
|
|
|
}); |
47
|
|
|
$viewDatas[] = 'devicesGraph'; |
48
|
|
|
|
49
|
|
|
$operatingSystemGraph = Cache::remember('Analytics.operatingsystem', $minutes, function () { |
50
|
|
|
return $this->buildOperatingSystemGraph(); |
51
|
|
|
}); |
52
|
|
|
$viewDatas[] = 'operatingSystemGraph';*/ |
53
|
|
|
|
54
|
|
|
$todayVisitors = Cache::remember('Analytics.todayvisitors', $minutes, function () { |
55
|
|
|
return $this->buildTodayVisitors(); |
56
|
|
|
}); |
57
|
|
|
$viewDatas[] = 'todayVisitors'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$usersCount = Cache::remember('Analytics.users.count', $minutes, function () { |
61
|
|
|
return User::count(); |
62
|
|
|
}); |
63
|
|
|
$viewDatas[] = 'usersCount'; |
64
|
|
|
|
65
|
|
|
$articlesCount = Cache::remember('Analytics.articles.count', $minutes, function () { |
66
|
|
|
return BlogArticle::count(); |
67
|
|
|
}); |
68
|
|
|
$viewDatas[] = 'articlesCount'; |
69
|
|
|
|
70
|
|
|
$commentsCount = Cache::remember('Analytics.comments.count', $minutes, function () { |
71
|
|
|
return BlogComment::count(); |
72
|
|
|
}); |
73
|
|
|
$viewDatas[] = 'commentsCount'; |
74
|
|
|
|
75
|
|
|
$breadcrumbs = $this->breadcrumbs; |
76
|
|
|
$viewDatas[] = 'breadcrumbs'; |
77
|
|
|
|
78
|
|
|
return view( |
79
|
|
|
'Admin.page.index', |
80
|
|
|
compact($viewDatas) |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|