Skip to content

Commit d4c0305

Browse files
author
Jad Joubran
committed
improve generator to call controller with StudlyCase
1 parent 75e26c4 commit d4c0305

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### v2.6.1
44
+ updated bower dependencies (angular material released 0.10.1)
55
+ added artisan generator for a new feature: **artisan ng:feature**
6+
+ improve generator to call controller with StudlyCase (StudlyCaseCtrl)
67

78
### v2.6.0
89
+ Update to [elixir 3.0](https://github.com/jadjoubran/laravel5-angular-material-starter/issues/20)

app/Console/Commands/AngularFeature.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Console\Commands;
44

55
use Illuminate\Console\Command;
6+
use File;
67

78
class AngularFeature extends Command{
89

@@ -32,11 +33,15 @@ public function __construct(){
3233
*/
3334
public function handle(){
3435
$name = $this->argument('name');
36+
$studly_name = studly_case($name);
3537

3638
$html = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.html.stub');
37-
$js = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.js.stub');
39+
$js = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.js.stub');
3840
$less = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.less.stub');
3941

42+
$html = str_replace('{{StudlyName}}', $studly_name, $html);
43+
$js = str_replace('{{StudlyName}}', $studly_name, $js);
44+
4045
$folder = __DIR__ . '/../../../angular/app/' . $name;
4146
if (is_dir($folder)){
4247
$this->info('Folder already exists');
@@ -45,15 +50,17 @@ public function handle(){
4550
}
4651

4752
//create folder
48-
\File::makeDirectory($folder, 0775, true);
53+
File::makeDirectory($folder, 0775, true);
4954

5055
//create view (.html)
51-
\File::put($folder . '/' . $name . '.html', $html);
56+
File::put($folder . '/' . $name . '.html', $html);
5257

5358
//create controller (.js)
54-
\File::put($folder . '/' . $name . '.js', $js);
59+
File::put($folder . '/' . $name . '.js', $js);
5560

5661
//create less file (.less)
5762
\File::put($folder . '/' . $name . '.less', $less);
63+
64+
$this->info('Feature created successfully.');
5865
}
5966
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div ng-controller="{{StudlyName}}Ctrl">
2+
3+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(function(){
2+
"use strict";
3+
4+
angular.module('app.controllers').controller('{{StudlyName}}Ctrl', function(){
5+
6+
7+
});
8+
9+
})();

readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ Open a new issue, I'd love to help.
5454
## Planned features
5555

5656
- artisan generator
57-
- improve artisan generator (default controller, default classes, etc..) + update documentation
58-
- dialog artisan generators
57+
- dialog artisan generators + update overview
5958
- Migrate to open source hosting
6059
- New demo pages: Toasts, Dialogs, Unsupported Browser, generators, Elixir, Rest API, loading bar, debugbar, filters, JWT
6160
- make gulp --production part of the automated release

0 commit comments

Comments
 (0)