|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PiFinder\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use JavaScript; |
|
6
|
|
|
use PiFinder\Device; |
|
7
|
|
|
use PiFinder\Services\Statistics; |
|
8
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
9
|
|
|
use PiFinder\Services\MarkdownParser; |
|
10
|
|
|
use Illuminate\Contracts\Cache\Repository as Cache; |
|
11
|
|
|
|
|
12
|
|
|
class WelcomeController extends Controller |
|
13
|
|
|
{ |
|
14
|
|
|
/* |
|
15
|
|
|
|-------------------------------------------------------------------------- |
|
16
|
|
|
| Welcome Controller |
|
17
|
|
|
|-------------------------------------------------------------------------- |
|
18
|
|
|
| |
|
19
|
|
|
| This controller renders the "marketing page" for the application and |
|
20
|
|
|
| is configured to only allow guests. Like most of the other sample |
|
21
|
|
|
| controllers, you are free to modify or remove it as you desire. |
|
22
|
|
|
| |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Create a new controller instance. |
|
27
|
|
|
*/ |
|
28
|
1 |
|
public function __construct() |
|
29
|
|
|
{ |
|
30
|
1 |
|
$this->middleware('guest'); |
|
31
|
1 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Show the application welcome screen to the user. |
|
35
|
|
|
* |
|
36
|
|
|
* @return Response |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function index() |
|
39
|
|
|
{ |
|
40
|
1 |
|
$devices = Device::onHomePage()->get(); |
|
41
|
|
|
|
|
42
|
1 |
|
return view('overview')->with(compact('devices')); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Show the getting started screen to the user. |
|
47
|
|
|
* |
|
48
|
|
|
* @param MarkdownParser $markdown |
|
49
|
|
|
* @param Cache $cache |
|
50
|
|
|
* @param Filesystem $file |
|
51
|
|
|
* |
|
52
|
|
|
* @return Response |
|
53
|
|
|
*/ |
|
54
|
|
|
public function gettingStarted(MarkdownParser $markdown, Cache $cache, Filesystem $file) |
|
55
|
|
|
{ |
|
56
|
1 |
|
$gettingStarted = $cache->remember('getting-started', 5, function () use ($markdown, $file) { |
|
57
|
1 |
|
$gettingStarted = $file->get(base_path('resources/getting-started/readme.md')); |
|
58
|
|
|
|
|
59
|
1 |
|
return $markdown->parse($gettingStarted); |
|
60
|
1 |
|
}); |
|
61
|
|
|
|
|
62
|
1 |
|
return view('getting-started')->with(compact('gettingStarted')); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Show the statistics screen to the user. |
|
67
|
|
|
* |
|
68
|
|
|
* @return Response |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function statistics(Statistics $statistics) |
|
71
|
|
|
{ |
|
72
|
1 |
|
$pokes_total = $statistics->totalPokes(); |
|
73
|
|
|
|
|
74
|
1 |
|
$devices_total = $statistics->totalDevices(); |
|
75
|
|
|
|
|
76
|
1 |
|
$pokes = $statistics->allPokes()->toArray(); |
|
77
|
|
|
|
|
78
|
1 |
|
$network_distribution = $statistics->networkDistribution()->toArray(); |
|
79
|
|
|
|
|
80
|
1 |
|
JavaScript::put(compact('pokes', 'network_distribution')); |
|
81
|
|
|
|
|
82
|
1 |
|
return view('statistics')->with(compact('pokes_total', 'devices_total')); |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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: