Skip to content

Commit 8fe23aa

Browse files
authored
Merge pull request #28 from saineshmamgain/main
fixes #27
2 parents 1f61c84 + 6e7c5ec commit 8fe23aa

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/Http/Controllers/GuiController.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Illuminate\Foundation\Validation\ValidatesRequests;
1010
use Illuminate\Routing\Controller;
1111
use Illuminate\Support\Facades\Artisan;
12+
use Illuminate\Support\Facades\Gate;
13+
use Illuminate\Support\Str;
1214
use Symfony\Component\Console\Command\Command;
1315
use Symfony\Component\Console\Input\InputArgument;
1416
use Symfony\Component\Console\Input\InputOption;
@@ -31,7 +33,7 @@ function run($command) {
3133

3234
$permissions = config('artisan-gui.permissions', []);
3335

34-
if (in_array($command->getName(), array_keys($permissions)) && !\Gate::check($permissions[$command->getName()]))
36+
if (in_array($command->getName(), array_keys($permissions)) && !Gate::check($permissions[$command->getName()]))
3537
abort(403);
3638

3739
$rules = $this->buildRules($command);
@@ -81,7 +83,7 @@ protected function prepareToJson(array $commands): array {
8183
foreach ($commands as $gKey => $group) {
8284
foreach ($group as $cKey => $command) {
8385

84-
if (($permission = $permissions[$command] ?? null) && !\Gate::check($permission)) {
86+
if (($permission = $permissions[$command] ?? null) && !Gate::check($permission)) {
8587
unset($commands[$gKey][$cKey]);
8688
continue;
8789
}
@@ -126,7 +128,7 @@ protected function optionsToArray(Command $command): ?array {
126128

127129
$options = array_map(function (InputOption $option) {
128130
return [
129-
'title' => \Str::of($option->getName())->snake()->replace('_', ' ')->title()->__toString(),
131+
'title' => Str::of($option->getName())->snake()->replace('_', ' ')->title()->__toString(),
130132
'name' => $option->getName(),
131133
'description' => $option->getDescription(),
132134
'shortcut' => $option->getShortcut(),
@@ -144,7 +146,7 @@ protected function argumentsToArray(Command $command): ?array {
144146
$definition = $command->getDefinition();
145147
$arguments = array_map(function (InputArgument $argument) {
146148
return [
147-
'title' => \Str::of($argument->getName())->snake()->replace('_', ' ')->title()->__toString(),
149+
'title' => Str::of($argument->getName())->snake()->replace('_', ' ')->title()->__toString(),
148150
'name' => $argument->getName(),
149151
'description' => $argument->getDescription(),
150152
'default' => empty($default = $argument->getDefault()) ? null : $default,
@@ -158,7 +160,7 @@ protected function argumentsToArray(Command $command): ?array {
158160

159161
protected function renameKeys(array $array): array {
160162
$keys = array_map(function ($key) {
161-
return \Str::title($key);
163+
return Str::title($key);
162164
}, array_keys($array));
163165

164166
return array_combine($keys, array_values($array));
@@ -192,4 +194,4 @@ protected function buildRules(Command $command) {
192194
return $rules;
193195
}
194196

195-
}
197+
}

src/Providers/GuiServiceProvider.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66

77
use Illuminate\Filesystem\Filesystem;
8+
use Illuminate\Support\Facades\Blade;
9+
use Illuminate\Support\Facades\Route;
10+
use Illuminate\Support\Facades\View;
811
use Illuminate\Support\ServiceProvider;
12+
use Illuminate\Support\Str;
913

1014

1115
class GuiServiceProvider extends ServiceProvider {
@@ -21,7 +25,7 @@ protected function registerRoutes() {
2125

2226
$middleware = config('artisan-gui.middlewares', []);
2327

24-
\Route::middleware($middleware)
28+
Route::middleware($middleware)
2529
->prefix(config('artisan-gui.prefix', '~') . 'artisan')
2630
->group(function () {
2731

@@ -47,7 +51,7 @@ public function register() {
4751

4852
public function boot() {
4953
$this->publishVendors();
50-
\View::share('guiRoot', $this->root);
54+
View::share('guiRoot', $this->root);
5155
}
5256

5357
protected function publishVendors() {
@@ -69,7 +73,7 @@ protected function discoverComponents($dir = null) {
6973
$prefix = 'gui';
7074

7175
if ($dir)
72-
$prefix .= '-' . \Str::of($dir)->replace(['\\', '/'], ' ')->slug();
76+
$prefix .= '-' . Str::of($dir)->replace(['\\', '/'], ' ')->slug();
7377

7478
$namespace = '';
7579

@@ -100,7 +104,7 @@ protected function loadComponents() {
100104
foreach ($components as $key => $group) {
101105
foreach ($group as $component) {
102106
$name = strtolower(last(explode('\\', $component)));
103-
\Blade::component($component, $name, $key);
107+
Blade::component($component, $name, $key);
104108
}
105109
}
106110

0 commit comments

Comments
 (0)