Completed
Push — develop ( 3d08a5...0d51b0 )
by Daniel
9s
created

HomeController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\Dashboard;
6
use Dingo\Api\Http;
7
use Dingo\Api\Routing\Helpers;
8
use Illuminate\Http\Request;
9
use JWTAuth;
10
11
class HomeController extends Controller
12
{
13
    use Helpers;
14
15
    public function redirect(Request $request)
16 4
    {
17 4
        $dashboard = Dashboard::where('user_id', $request->user()->user_id)->first();
18 4
        if (empty($dashboard->dashboard_id))
19
        {
20
            $dashboard = new dashboard;
21
            $dashboard->dashboard_name = 'Default';
22
            $dashboard->access         = 0;
23
            $request->user()->dashboards()->save($dashboard);
24
        }
25
        return redirect()->route('dashboard.show', ['id' => $dashboard->dashboard_id]);
26
    }
27
28
    public function index(Request $request) {
29
        $dashboards = $this->api->be(auth()->user())->get('/api/dashboard');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        return view('home', ['dashboards' => $dashboards, 'request' => $request]);
31
    }
32
33
    public function show(Request $request)
34
    {
35
        $token      = JWTAuth::fromUser(auth()->user());
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        $dashboards = $this->api->be(auth()->user())->get('/api/dashboard');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        if (Dashboard::find($request->route('dashboard_id')))
38 2
        {
39
            $dash    = $this->api->be(auth()->user())->get('/api/dashboard/'.$request->route('dashboard_id'));
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40 2
            $widgets = $this->api->be(auth()->user())->get('/api/widget');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41 2
        }
42 2
        else {
43 2
            return redirect()->route('home');
44 2
        }
45 2
        return view('home', ['dashboards' => $dashboards, 'request' => $request, 'dash_widgets' => $dash['widgets'], 'token' => $token, 'dash_details' => $dash['dashboard'], 'widgets' => $widgets]);
46 2
    }
47
48
    public function about() {
49
        $versions = $this->api->be(auth()->user())->get('/api/info');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50 2
        $stats    = $this->api->be(auth()->user())->get('/api/stats');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        return view('general.about', ['versions' => $versions, 'stats' => $stats]);
52
    }
53
}
54