@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(! function_exists('getRouteName')) { |
|
4 | - function getRouteName(){ |
|
3 | +if (!function_exists('getRouteName')) { |
|
4 | + function getRouteName() { |
|
5 | 5 | $routeName = config('easy_panel.route_prefix'); |
6 | 6 | $routeName = trim($routeName, '/'); |
7 | 7 | $routeName = str_replace('/', '.', $routeName); |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(! function_exists('get_icon')) { |
|
13 | - function get_icon($type){ |
|
12 | +if (!function_exists('get_icon')) { |
|
13 | + function get_icon($type) { |
|
14 | 14 | $array = [ |
15 | 15 | 'file-text' => ['posts', 'article', 'stories', 'post', 'articles', 'story'], |
16 | 16 | 'users' => ['users', 'user', 'accounts', 'account', 'admins', 'admin', 'employee', 'employees'], |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | 'truck' => ['product', 'products', 'shops', 'shop'], |
28 | 28 | 'message-circle' => ['comments', 'messages', 'pm', 'comment', 'message', 'chats', 'chat'], |
29 | 29 | ]; |
30 | - foreach ($array as $key => $arrayValues){ |
|
31 | - if(in_array($type, $arrayValues)){ |
|
30 | + foreach ($array as $key => $arrayValues) { |
|
31 | + if (in_array($type, $arrayValues)) { |
|
32 | 32 | $val = $key; |
33 | 33 | } |
34 | 34 | } |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(! function_exists('registerActionRoutes')){ |
|
39 | +if (!function_exists('registerActionRoutes')) { |
|
40 | 40 | function registerActionRoutes($action, $component, $crudConfig) |
41 | 41 | { |
42 | - Route::prefix($action)->name("$action.")->group(function () use ($component, $crudConfig, $action) { |
|
42 | + Route::prefix($action)->name("$action.")->group(function() use ($component, $crudConfig, $action) { |
|
43 | 43 | |
44 | - if(@class_exists("$component\\Read")) { |
|
44 | + if (@class_exists("$component\\Read")) { |
|
45 | 45 | Route::get('/', "$component\\Read")->name('read'); |
46 | 46 | } |
47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | if (@$crudConfig['update'] and @class_exists("$component\\Update")) { |
53 | - Route::get('/update/{' . $action . '}', "$component\\Update")->name('update'); |
|
53 | + Route::get('/update/{'.$action.'}', "$component\\Update")->name('update'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | }); |
@@ -40,17 +40,17 @@ |
||
40 | 40 | |
41 | 41 | protected function getStub() |
42 | 42 | { |
43 | - return __DIR__ . DIRECTORY_SEPARATOR. "..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."{$this->file}.stub"; |
|
43 | + return __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."{$this->file}.stub"; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | private function buildBlade() |
47 | 47 | { |
48 | - $stub = $this->files->get(__DIR__ . DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."blade".DIRECTORY_SEPARATOR."{$this->file}.blade.stub"); |
|
48 | + $stub = $this->files->get(__DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."blade".DIRECTORY_SEPARATOR."{$this->file}.blade.stub"); |
|
49 | 49 | $newStub = $this->stubParser->parseBlade($stub); |
50 | 50 | |
51 | 51 | $path = $this->viewPath("livewire".DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."{$this->getNameInput()}".DIRECTORY_SEPARATOR."{$this->file}.blade.php"); |
52 | 52 | |
53 | - if (! $this->files->isDirectory(dirname($path))) { |
|
53 | + if (!$this->files->isDirectory(dirname($path))) { |
|
54 | 54 | $this->files->makeDirectory(dirname($path), 0755, true); |
55 | 55 | } |
56 | 56 |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle() |
25 | 25 | { |
26 | - if(!$this->option('model')){ |
|
26 | + if (!$this->option('model')) { |
|
27 | 27 | $this->error("Model option must have a value"); |
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | 31 | $name = strtolower($this->getNameInput()); |
32 | 32 | |
33 | - if($name != strtolower($this->option('model'))){ |
|
33 | + if ($name != strtolower($this->option('model'))) { |
|
34 | 34 | $this->warn("'{$name}' must be equal to model name"); |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $path = resource_path("cruds/{$name}.php"); |
39 | 39 | |
40 | - if($this->files->exists($path) and !$this->option('force')){ |
|
40 | + if ($this->files->exists($path) and !$this->option('force')) { |
|
41 | 41 | $this->warn("'{$name}' already exists in CRUDs config"); |
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - if (! $this->files->isDirectory(dirname($path))) { |
|
45 | + if (!$this->files->isDirectory(dirname($path))) { |
|
46 | 46 | $this->files->makeDirectory(dirname($path), 0755, true); |
47 | 47 | } |
48 | 48 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $model = $this->qualifyModel($this->option('model')); |
78 | 78 | |
79 | - if(!class_exists($model)){ |
|
79 | + if (!class_exists($model)) { |
|
80 | 80 | $this->warn("Model option should be valid and model should be exist"); |
81 | 81 | die(); |
82 | 82 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | private function withAuth() |
88 | 88 | { |
89 | 89 | $fillableList = $this->getFillableList(); |
90 | - if(!in_array('user_id', $fillableList)){ |
|
90 | + if (!in_array('user_id', $fillableList)) { |
|
91 | 91 | return 'true'; |
92 | 92 | } |
93 | 93 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | { |
106 | 106 | $fillableList = $this->getFillableList(); |
107 | 107 | $array = []; |
108 | - foreach ($fillableList as $fillable){ |
|
109 | - if(!Str::contains($fillable, 'id')){ |
|
108 | + foreach ($fillableList as $fillable) { |
|
109 | + if (!Str::contains($fillable, 'id')) { |
|
110 | 110 | $array[] = "'$fillable'"; |
111 | 111 | } |
112 | 112 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | $this->action = $action; |
28 | 28 | } |
29 | 29 | |
30 | - public function render(){ |
|
30 | + public function render() { |
|
31 | 31 | $name = $this->name; |
32 | 32 | |
33 | 33 | // Create an instance of input class |
34 | 34 | // then call handle() method to get input as a steing |
35 | - if(!is_array($this->type)) { |
|
35 | + if (!is_array($this->type)) { |
|
36 | 36 | $inputStringClass = static::classMap[$this->type]; |
37 | 37 | $input = (new $inputStringClass())->handle($name); |
38 | 38 | } else { |
@@ -8,8 +8,8 @@ |
||
8 | 8 | public function handle($name, $values, $action) |
9 | 9 | { |
10 | 10 | return "<select wire:model='$name' class=\"form-control @error('$name') is-invalid @enderror\" id='input$name'> |
11 | - @foreach(config('easy_panel.crud.$action.fields.$name')['select'] as " . '$key => $value' . ") |
|
12 | - <option value='{{ " . '$key' . " }}'>{{ " . '$value' . " }}</option> |
|
11 | + @foreach(config('easy_panel.crud.$action.fields.$name')['select'] as ".'$key => $value'.") |
|
12 | + <option value='{{ " . '$key'." }}'>{{ ".'$value'." }}</option> |
|
13 | 13 | @endforeach |
14 | 14 | </select>"; |
15 | 15 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | public function register() |
35 | 35 | { |
36 | 36 | // Here we merge config with 'easy_panel' key |
37 | - $this->mergeConfigFrom(__DIR__ . '/../config/easy_panel_config.php', 'easy_panel'); |
|
37 | + $this->mergeConfigFrom(__DIR__.'/../config/easy_panel_config.php', 'easy_panel'); |
|
38 | 38 | |
39 | 39 | // Check the status of module |
40 | - if(!config('easy_panel.enable')) { |
|
40 | + if (!config('easy_panel.enable')) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function boot() |
49 | 49 | { |
50 | - if(!config('easy_panel.enable')) { |
|
50 | + if (!config('easy_panel.enable')) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Load Views with 'admin::' prefix |
64 | - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'admin'); |
|
64 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'admin'); |
|
65 | 65 | |
66 | 66 | // Register Middleware |
67 | 67 | $this->registerMiddlewareAlias(); |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | |
76 | 76 | private function defineRoutes() |
77 | 77 | { |
78 | - if(!$this->app->routesAreCached()) { |
|
78 | + if (!$this->app->routesAreCached()) { |
|
79 | 79 | Route::prefix(config('easy_panel.route_prefix')) |
80 | 80 | ->middleware(['web', 'auth', 'isAdmin', 'LangChanger']) |
81 | - ->name(getRouteName() . '.') |
|
82 | - ->group(__DIR__ . '/routes.php'); |
|
81 | + ->name(getRouteName().'.') |
|
82 | + ->group(__DIR__.'/routes.php'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | |
106 | 106 | private function mergePublishes() |
107 | 107 | { |
108 | - $this->publishes([__DIR__ . '/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
108 | + $this->publishes([__DIR__.'/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
109 | 109 | |
110 | - $this->publishes([__DIR__ . '/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
110 | + $this->publishes([__DIR__.'/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
111 | 111 | |
112 | - $this->publishes([__DIR__ . '/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
112 | + $this->publishes([__DIR__.'/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
113 | 113 | |
114 | - $this->publishes([__DIR__ . '/../database/migrations/2020_09_05_99999_create_todos_table.php' => base_path('/database/migrations/' . date('Y_m_d') . '_99999_create_admin_todos_table.php')], 'easy-panel-migrations'); |
|
114 | + $this->publishes([__DIR__.'/../database/migrations/2020_09_05_99999_create_todos_table.php' => base_path('/database/migrations/'.date('Y_m_d').'_99999_create_admin_todos_table.php')], 'easy-panel-migrations'); |
|
115 | 115 | |
116 | 116 | $this->publishes([__DIR__.'/../resources/lang' => resource_path('/lang')], 'easy-panel-lang'); |
117 | 117 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public function handle($request, Closure $next) |
12 | 12 | { |
13 | - if(!AuthFacade::checkIsAdmin(auth()->user()->id)){ |
|
13 | + if (!AuthFacade::checkIsAdmin(auth()->user()->id)) { |
|
14 | 14 | return redirect(config('easy_panel.redirect_unauthorized')); |
15 | 15 | } |
16 | 16 |