Passed
Push — develop ( aa9ac7...096b8e )
by Nikita
05:39
created

HomeController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 73
ccs 0
cts 16
cp 0
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A help() 0 3 1
A __construct() 0 3 1
A sendBug() 0 9 1
A update() 0 4 1
A reportBug() 0 4 1
A index() 0 9 1
1
<?php
2
3
namespace Gameap\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use \Illuminate\Http\Response;
7
use Gameap\Services\InfoService;
8
use Gameap\Services\GlobalApi;
9
use Gameap\Http\Requests\SendBugRequest;
10
use Cache;
11
12
class HomeController extends Controller
13
{
14
    /**
15
     * Create a new controller instance.
16
     *
17
     * @return void
18
     */
19
    public function __construct()
20
    {
21
        $this->middleware('auth');
22
    }
23
24
    /**
25
     * Show the application dashboard.
26
     *
27
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
28
     */
29
    public function index()
30
    {
31
        $latestVersion = Cache::remember('latestVersion', 3600, function () {
32
            return InfoService::latestRelease();
33
        });
34
35
        $modules = app()['modules']->getCached();
36
        
37
        return view('home', compact('latestVersion', 'modules'));
38
    }
39
40
    /**
41
     * Show help information (GameAP resources etc)
42
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
43
     */
44
    public function help()
45
    {
46
        return view('help');
47
    }
48
49
    /**
50
     * Report a bug
51
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
52
     */
53
    public function reportBug()
54
    {
55
        $extensions = get_loaded_extensions();
56
        return view('report_bug', compact('extensions'));
57
    }
58
59
    /**
60
     * Send bug
61
     * 
62
     * @param SendBugRequest $request
63
     * @return \Illuminate\Http\RedirectResponse
64
     * @throws \Gameap\Exceptions\Services\GlobalApiException
65
     */
66
    public function sendBug(SendBugRequest $request)
67
    {
68
        GlobalApi::sendBug(
69
            $request->input('summary'),
70
            $request->input('description')
71
        );
72
73
        return redirect()->route('report_bug')
74
            ->with('success', __('home.send_bug_success_msg'));
75
    }
76
77
    /**
78
     * Upgrade panel page
79
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
80
     */
81
    public function update()
82
    {
83
        $latestVersion = InfoService::latestRelease();
84
        return view('update', compact('latestVersion'));
85
    }
86
}
87