1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use EasyPanel\Contracts\CRUDComponent; |
4
|
|
|
|
5
|
|
|
if(! function_exists('getRouteName')) { |
6
|
|
|
function getRouteName(){ |
7
|
|
|
$routeName = config('easy_panel.route_prefix'); |
8
|
|
|
$routeName = trim($routeName, '/'); |
9
|
|
|
$routeName = str_replace('/', '.', $routeName); |
10
|
|
|
return $routeName; |
11
|
|
|
} |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
if(! function_exists('getCrudConfig')) { |
15
|
|
|
function getCrudConfig($name){ |
16
|
|
|
$namespace = "\\App\\CRUD\\{$name}Component"; |
17
|
|
|
|
18
|
|
|
if (!class_exists($namespace)){ |
19
|
|
|
abort(403, "Class with {$namespace} namespace doesn't exist"); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$instance = app()->make($namespace); |
23
|
|
|
|
24
|
|
|
if (!$instance instanceof CRUDComponent){ |
25
|
|
|
abort(403, "{$namespace} should implement CRUDComponent interface"); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
return $instance; |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if(! function_exists('crud')) { |
33
|
|
|
function crud($name){ |
34
|
|
|
return \EasyPanel\Models\CRUD::query()->where('name', $name)->first(); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if(! function_exists('get_icon')) { |
39
|
|
|
function get_icon($type){ |
40
|
|
|
$array = [ |
41
|
|
|
'file-text' => ['posts', 'article', 'stories', 'post', 'articles', 'story'], |
42
|
|
|
'users' => ['users', 'user', 'accounts', 'account', 'admins', 'admin', 'employee', 'employees'], |
43
|
|
|
'file' => ['files', 'file'], |
44
|
|
|
'mic' => ['episode', 'episodes', 'voices', 'voice'], |
45
|
|
|
'book' => ['book', 'books'], |
46
|
|
|
'tag' => ['tag', 'tags'], |
47
|
|
|
'bookmark' => ['bookmarks', 'bookmark'], |
48
|
|
|
'heart' => ['likes', 'like', 'favorite', 'favorites'], |
49
|
|
|
'music' => ['musics', 'music', 'audios', 'audio'], |
50
|
|
|
'bell' => ['notifications', 'notification'], |
51
|
|
|
'layers' => ['request', 'requests'], |
52
|
|
|
'settings' => ['settings', 'setting'], |
53
|
|
|
'truck' => ['product', 'products', 'shops', 'shop'], |
54
|
|
|
'message-circle' => ['comments', 'messages', 'pm', 'comment', 'message', 'chats', 'chat'], |
55
|
|
|
]; |
56
|
|
|
foreach ($array as $key => $arrayValues){ |
57
|
|
|
if(in_array($type, $arrayValues)){ |
58
|
|
|
$val = $key; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
return $val ?? 'grid'; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|