File tree Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,16 @@ class BlogPost extends Model
167167}
168168```
169169
170+ ### Creating models
171+
172+ In addition of the ` make:model ` artisan command, you will now have access to
173+ ` uuid:make:model ` which has all the functionality of the standard ` make:model `
174+ command (with exception of not being able to create a pivot model):
175+
176+ ``` bash
177+ php artisan uuid:make:model Models/Post --all
178+ ```
179+
170180## Running the tests
171181
172182To run the test suite you can use the following commands:
Original file line number Diff line number Diff line change 4747 "test:style" : " php-cs-fixer fix --config=.php_cs --allow-risky=yes --dry-run --diff --verbose" ,
4848 "test:unit" : " phpunit" ,
4949 "fix:style" : " php-cs-fixer fix --config=.php_cs --allow-risky=yes --diff --verbose"
50+ },
51+ "extra" : {
52+ "laravel" : {
53+ "providers" : [
54+ " GoldSpecDigital\\ LaravelEloquentUUID\\ UuidServiceProvider"
55+ ]
56+ }
5057 }
5158}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace DummyNamespace;
4+
5+ use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Model;
6+
7+ class DummyClass extends Model
8+ {
9+ //
10+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace GoldSpecDigital \LaravelEloquentUUID \Console ;
6+
7+ use Illuminate \Foundation \Console \ModelMakeCommand ;
8+
9+ class UuidModelCommand extends ModelMakeCommand
10+ {
11+ /**
12+ * The console command name.
13+ *
14+ * @var string
15+ */
16+ protected $ name = 'uuid:make:model ' ;
17+
18+ /**
19+ * The console command description.
20+ *
21+ * @var string
22+ */
23+ protected $ description = 'Create a new Eloquent UUID model class ' ;
24+
25+ /**
26+ * The type of class being generated.
27+ *
28+ * @var string
29+ */
30+ protected $ type = 'UUID Model ' ;
31+
32+ /**
33+ * Get the stub file for the generator.
34+ *
35+ * @return string
36+ */
37+ protected function getStub (): string
38+ {
39+ return __DIR__ . '/stubs/model.stub ' ;
40+ }
41+
42+ /**
43+ * Get the console command options.
44+ *
45+ * @return array
46+ */
47+ protected function getOptions (): array
48+ {
49+ // Remove the pivot option from the parent class.
50+ return array_filter (
51+ parent ::getOptions (),
52+ function (array $ option ): bool {
53+ return $ option [0 ] !== 'pivot ' ;
54+ }
55+ );
56+ }
57+
58+ /**
59+ * Get the value of a command option.
60+ *
61+ * @param string|null $key
62+ * @return string|array|bool|null
63+ */
64+ public function option ($ key = null )
65+ {
66+ if ($ key === 'pivot ' ) {
67+ return false ;
68+ }
69+
70+ return parent ::option ($ key );
71+ }
72+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace GoldSpecDigital \LaravelEloquentUUID ;
6+
7+ use GoldSpecDigital \LaravelEloquentUUID \Console \UuidModelCommand ;
8+ use Illuminate \Support \ServiceProvider ;
9+
10+ class UuidServiceProvider extends ServiceProvider
11+ {
12+ /**
13+ * Bootstrap any application services.
14+ */
15+ public function boot (): void
16+ {
17+ if ($ this ->app ->runningInConsole ()) {
18+ $ this ->commands ([
19+ UuidModelCommand::class,
20+ ]);
21+ }
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments