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('get_icon')) { |
33
|
|
|
function get_icon($type){ |
34
|
|
|
$array = [ |
35
|
|
|
'file-text' => ['posts', 'article', 'stories', 'post', 'articles', 'story'], |
36
|
|
|
'users' => ['users', 'user', 'accounts', 'account', 'admins', 'admin', 'employee', 'employees'], |
37
|
|
|
'file' => ['files', 'file'], |
38
|
|
|
'mic' => ['episode', 'episodes', 'voices', 'voice'], |
39
|
|
|
'book' => ['book', 'books'], |
40
|
|
|
'tag' => ['tag', 'tags'], |
41
|
|
|
'bookmark' => ['bookmarks', 'bookmark'], |
42
|
|
|
'heart' => ['likes', 'like', 'favorite', 'favorites'], |
43
|
|
|
'music' => ['musics', 'music', 'audios', 'audio'], |
44
|
|
|
'bell' => ['notifications', 'notification'], |
45
|
|
|
'layers' => ['request', 'requests'], |
46
|
|
|
'settings' => ['settings', 'setting'], |
47
|
|
|
'truck' => ['product', 'products', 'shops', 'shop'], |
48
|
|
|
'message-circle' => ['comments', 'messages', 'pm', 'comment', 'message', 'chats', 'chat'], |
49
|
|
|
]; |
50
|
|
|
foreach ($array as $key => $arrayValues){ |
51
|
|
|
if(in_array($type, $arrayValues)){ |
52
|
|
|
$val = $key; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
return $val ?? 'grid'; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if(! function_exists('registerActionRoutes')){ |
60
|
|
|
function registerActionRoutes($prefix, $component, $crudConfig) |
61
|
|
|
{ |
62
|
|
|
Route::prefix($prefix)->name("$prefix.")->group(function () use ($component, $crudConfig) { |
63
|
|
|
|
64
|
|
|
if(@class_exists("$component\\Read")) { |
65
|
|
|
Route::get('/', "$component\\Read")->name('read'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (@$crudConfig->create and @class_exists("$component\\Create")) { |
69
|
|
|
Route::get('/create', "$component\\Create")->name('create'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (@$crudConfig->update and @class_exists("$component\\Update")) { |
73
|
|
|
Route::get('/update/{' . $action . '}', "$component\\Update")->name('update'); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
}); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|