Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function index() |
||
11 | { |
||
12 | if (empty(config('laravel-analytics.view_id'))) { |
||
13 | return view('back.statistics.notconfigured'); |
||
14 | } |
||
15 | |||
16 | $visitors = Analytics::fetchTotalVisitorsAndPageViews(Period::days(365)) |
||
17 | ->groupBy(function (array $visitorStatistics) { |
||
18 | return $visitorStatistics['date']->format('Y-m'); |
||
19 | }) |
||
20 | ->map(function ($visitorStatistics, $yearMonth) { |
||
21 | list($year, $month) = explode('-', $yearMonth); |
||
22 | |||
23 | return [ |
||
24 | 'date' => "{$month}-{$year}", |
||
25 | 'visitors' => $visitorStatistics->sum('visitors'), |
||
26 | 'pageViews' => $visitorStatistics->sum('pageViews'), |
||
27 | ]; |
||
28 | }) |
||
29 | ->values(); |
||
30 | |||
31 | $pages = Analytics::fetchMostVisitedPages(Period::days(365)); |
||
32 | $referrers = Analytics::fetchTopReferrers(Period::days(365)); |
||
33 | $browsers = Analytics::fetchTopBrowsers(Period::days(365)); |
||
34 | |||
35 | return view('back.statistics.index')->with(compact('visitors', 'pages', 'referrers', 'browsers')); |
||
|
|||
36 | } |
||
37 | } |
||
38 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: