Skip to content

Commit 280ad5a

Browse files
committed
Minor fixes on name case
1 parent 5000d7f commit 280ad5a

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/Console/Commands/PageBackpackCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function handle()
6464

6565
$this->infoBlock("Creating {$name->replace('_', ' ')->title()} page");
6666

67-
$this->progressBlock("Creating view <fg=blue>resources/views/${filePath}.php</>");
67+
$this->progressBlock("Creating view <fg=blue>resources/views/${filePath}.blade.php</>");
6868

6969
// check if the file already exists
7070
if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($filePath)) {
@@ -78,11 +78,14 @@ public function handle()
7878
// create page view
7979
$stub = $this->buildClass($filePath);
8080
$stub = str_replace('layout', $layout, $stub);
81-
$stub = str_replace('DummyName', $name->studly(), $stub);
81+
$stub = str_replace('Dummy Name', $name->replace('_', ' ')->title(), $stub);
8282
$this->files->put($fullpath, $stub);
8383

8484
$this->closeProgressBlock();
8585

86+
// Clean up name
87+
$name = $name->replace('_', ' ')->replace('-', ' ')->title();
88+
8689
// create controller
8790
$this->call('backpack:page-controller', [
8891
'name' => $name,
@@ -96,13 +99,13 @@ public function handle()
9699

97100
// create the sidebar item
98101
$this->call('backpack:add-sidebar-content', [
99-
'code' => "<li class=\"nav-item\"><a class=\"nav-link\" href=\"{{ backpack_url('{$name->kebab()}') }}\"><i class=\"nav-icon la la-question\"></i> {$name->title()}</a></li>",
102+
'code' => "<li class=\"nav-item\"><a class=\"nav-link\" href=\"{{ backpack_url('{$name->kebab()}') }}\"><i class=\"nav-icon la la-question\"></i> {$name}</a></li>",
100103
]);
101104

102105
$url = Str::of(config('app.url'))->finish('/')->append("admin/{$name->kebab()}");
103106

104107
$this->newLine();
105-
$this->note("Page {$name->title()} created.");
108+
$this->note("Page {$name} created.");
106109
$this->note("Go to <fg=blue>$url</> to access your new page.");
107110
$this->newLine();
108111
}

src/Console/Commands/PageControllerBackpackCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ protected function getDefaultNamespace($rootNamespace)
132132
*/
133133
protected function replacePathStrings(&$stub)
134134
{
135+
$viewName = $this->getNameInput()->snake('_');
135136
$pathDot = Str::of($this->option('view-path'))
136137
->replace('/', '.')
137138
->replace('\\', '.')
138-
->append('.'.$this->getNameInput()->lcfirst())
139+
->append('.'.$viewName)
139140
->trim('.');
140141
$pathSlash = $pathDot->replace('.', '/');
141142

@@ -158,6 +159,7 @@ protected function replaceNameStrings(&$stub)
158159

159160
$stub = str_replace('DummyName', $name, $stub);
160161
$stub = str_replace('dummyName', $name->lcfirst(), $stub);
162+
$stub = str_replace('Dummy Name', $name->kebab()->replace('-', ' ')->title(), $stub);
161163

162164
return $this;
163165
}

src/Console/stubs/page-controller.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DummyClassController extends Controller
1414
public function index()
1515
{
1616
return view('dummy.path', [
17-
'title' => 'DummyName',
17+
'title' => 'Dummy Name',
1818
'breadcrumbs' => [
1919
trans('backpack::crud.admin') => backpack_url('dashboard'),
2020
'DummyName' => false,

src/Console/stubs/page.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('content')
44
<div class="jumbotron">
5-
<h1 class="mb-4">DummyName</h1>
5+
<h1 class="mb-4">Dummy Name</h1>
66

77
<p>Go to <code>{{ $page }}</code> to edit this view or <code>{{ $controller }}</code> to edit the controller.</p>
88
</div>

0 commit comments

Comments
 (0)