Skip to content

Commit

Permalink
Merge pull request #51 from daverogers/cleanup-and-remove-all
Browse files Browse the repository at this point in the history
Cleanup and remove "all" option
  • Loading branch information
michael-mcmullen authored Oct 11, 2021
2 parents 71e44bf + f84b13e commit 602f415
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 273 deletions.
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ This command comes with a bunch of different options, please see below for each
* --table=
* This parameter if filled in will generate a model for the given table
* You can also pass in a list of tables using comma separated values
* --all=[_true|false (default)_]
* If this flag is present, then the table command will be ignored
* This will generate a model for **all** tables found in your database
* You can optionally specify a whitelist/blacklist in `config/modelfromtable.php`
* _Note: by default, this command will only ignore the `migrations` table_
* When omitted, **all** tables will generate a model
* In this scenario you can optionally specify a whitelist/blacklist in `config/modelfromtable.php`
* `migrations` table will be blacklisted by default
* --connection=
* By default, if omitted, the default connection found in `config/database.php` will be used
* To specify a connection, first ensure that it exists in your `config/database.php`
Expand Down Expand Up @@ -86,16 +84,10 @@ php artisan generate:modelfromtable --table=users
php artisan generate:modelfromtable --table=users,posts
```

### Generating all tables
### Changing to another connection found in `database.php`

```
php artisan generate:modelfromtable --all=true
```

### Changing to another connection found in `database.php` and generating models for all tables

```
php artisan generate:modelfromtable --connection=spark --all=true
php artisan generate:modelfromtable --connection=spark
```

### Changing the folder where to /app/Models
Expand All @@ -105,7 +97,7 @@ php artisan generate:modelfromtable --table=user --folder=app\Models
```

## Configuration file for saving defaults, dynamic lambdas
A [config file](https://github.com/laracademy/generators/blob/master/config/modelfromtable.php) should be in your project's config folder (if not, you can easily create it). Through this, you can set defaults you commonly use to cut down on the input your command line call requires. For example: `'all' => true`. Then when you run `php artisan generate:modelfromtable` all tables will be generated by default. Some fields, like `namespace`, accept a static value or, more powerfully, a lambda to generate dynamic values. Additional fields not available to the CLI are available in the config. See below.
A [config file](https://github.com/laracademy/generators/blob/master/config/modelfromtable.php) should be in your project's config folder (if not, you can easily create it). Through this, you can set defaults you commonly use to cut down on the input your command line call requires. Some fields, like `namespace`, accept a static value or, more powerfully, a lambda to generate dynamic values. Additional fields not available to the CLI are available in the config. See below.

### Primary Key, using lamba (config only)
Some apps do not use the Laravel default of `id`, so say your table name prefixes the primary key...
Expand Down
2 changes: 0 additions & 2 deletions config/modelfromtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

'debug' => false,

'all' => false,

'singular' => false,

'overwrite' => false,
Expand Down
Loading

0 comments on commit 602f415

Please sign in to comment.