|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Return the auth account instance class. |
|
5
|
|
|
* |
|
6
|
|
|
* @return \App\Model\Account|\Illuminate\Contracts\Auth\Authenticatable |
|
7
|
|
|
*/ |
|
8
|
|
|
function account() |
|
9
|
|
|
{ |
|
10
|
|
|
return auth()->user(); |
|
|
|
|
|
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Return the webshelf framework version. |
|
15
|
|
|
* |
|
16
|
|
|
* @return App\Framework |
|
17
|
|
|
*/ |
|
18
|
|
|
function framework() |
|
19
|
|
|
{ |
|
20
|
|
|
return app(App\Framework::class); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @return \App\Classes\SettingsManager |
|
25
|
|
|
*/ |
|
26
|
|
|
function settings() |
|
27
|
|
|
{ |
|
28
|
|
|
return app(\App\Classes\SettingsManager::class); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return \App\Classes\PluginManager |
|
33
|
|
|
*/ |
|
34
|
|
|
function plugins() |
|
35
|
|
|
{ |
|
36
|
|
|
return app(\App\Classes\PluginManager::class); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return \App\Classes\Library\StyleCSS\Style |
|
41
|
|
|
*/ |
|
42
|
|
|
function css() |
|
43
|
|
|
{ |
|
44
|
|
|
return app(\App\Classes\Library\StyleCSS\Style::class); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param string $table |
|
49
|
|
|
* @param int $id |
|
50
|
|
|
* @return App\Classes\Interfaces\Linkable |
|
51
|
|
|
*/ |
|
52
|
|
|
function getMorphedModel(string $table, int $id) |
|
53
|
|
|
{ |
|
54
|
|
|
return app($table)->whereKey($id)->first(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
function currentURI() |
|
61
|
|
|
{ |
|
62
|
|
|
$route = basename(request()->path()) ?: 'index'; |
|
63
|
|
|
|
|
64
|
|
|
return $route != '' ? $route : 'index'; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Return an array of the segmented url path. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
function segmentRequestPath() |
|
73
|
|
|
{ |
|
74
|
|
|
$path = app('request')->path(); |
|
75
|
|
|
|
|
76
|
|
|
if ($path == '/') { |
|
77
|
|
|
return ['index']; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return explode('/', $path); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Turn a boolean value into readable data. |
|
85
|
|
|
* true = Active |
|
86
|
|
|
* false = Inactive. |
|
87
|
|
|
* |
|
88
|
|
|
* @param $boolean |
|
89
|
|
|
* @param null $trueMessage |
|
90
|
|
|
* @param null $falseMessage |
|
91
|
|
|
* @return string |
|
92
|
|
|
* @internal param null $true |
|
93
|
|
|
* @internal param null $false |
|
94
|
|
|
* @deprecated |
|
95
|
|
|
*/ |
|
96
|
|
|
function bool2Status($boolean, $trueMessage = null, $falseMessage = null) |
|
97
|
|
|
{ |
|
98
|
|
|
if ($boolean == true) { |
|
99
|
|
|
return '<span class="status green">'.($trueMessage ?: 'Active').'</span>'; |
|
100
|
|
|
} else { |
|
101
|
|
|
return '<span class="status red">'.($falseMessage ?: 'Inactive').'</span>'; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
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: