|
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'); |
|
|
|
|
|
|
30
|
|
|
return view('home', ['dashboards' => $dashboards, 'request' => $request]); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function show(Request $request) |
|
34
|
|
|
{ |
|
35
|
|
|
$token = JWTAuth::fromUser(auth()->user()); |
|
|
|
|
|
|
36
|
|
|
$dashboards = $this->api->be(auth()->user())->get('/api/dashboard'); |
|
|
|
|
|
|
37
|
|
|
if (Dashboard::find($request->route('dashboard_id'))) |
|
38
|
2 |
|
{ |
|
39
|
|
|
$dash = $this->api->be(auth()->user())->get('/api/dashboard/'.$request->route('dashboard_id')); |
|
|
|
|
|
|
40
|
2 |
|
$widgets = $this->api->be(auth()->user())->get('/api/widget'); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
50
|
2 |
|
$stats = $this->api->be(auth()->user())->get('/api/stats'); |
|
|
|
|
|
|
51
|
|
|
return view('general.about', ['versions' => $versions, 'stats' => $stats]); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
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.