Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented --noseed option #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ Example:
php artisan iseed users --noindex
```

### noseed
By using --noseed the seeder file will be generated, but will not be included in the `DatabaseSeeder.php`

Example:
```
php artisan iseed users --noseed
```

## Usage

To generate a seed file for your users table simply call: `\Iseed::generateSeed('users', 'connectionName', 'numOfRows');`. `connectionName` and `numOfRows` are not required arguments.
Expand Down
12 changes: 9 additions & 3 deletions src/Orangehill/Iseed/Iseed.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ public function readStubFile($file)
* @param int $max
* @param string $prerunEvent
* @param string $postunEvent
* @param bool $seeded
* @return bool
* @throws Orangehill\Iseed\TableNotFoundException
*/
public function generateSeed($table, $prefix=null, $suffix=null, $database = null, $max = 0, $chunkSize = 0, $exclude = null, $prerunEvent = null, $postrunEvent = null, $dumpAuto = true, $indexed = true, $orderBy = null, $direction = 'ASC')
public function generateSeed($table, $prefix=null, $suffix=null, $database = null, $max = 0, $chunkSize = 0, $exclude = null, $prerunEvent = null, $postrunEvent = null, $dumpAuto = true, $indexed = true, $orderBy = null, $direction = 'ASC', $seeded = true)
{
if (!$database) {
$database = config('database.default');
Expand Down Expand Up @@ -112,8 +113,13 @@ public function generateSeed($table, $prefix=null, $suffix=null, $database = nul
$this->composer->dumpAutoloads();
}

// Update the DatabaseSeeder.php file
return $this->updateDatabaseSeederRunMethod($className) !== false;
// Update the DatabaseSeeder.php file if seeded option is on
if ($seeded) {
return $this->updateDatabaseSeederRunMethod($className) !== false;
} else {
return true;
}

}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Orangehill/Iseed/IseedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function fire()
$direction = $this->option('direction');
$prefix = $this->option('classnameprefix');
$suffix = $this->option('classnamesuffix');
$seeded = !$this->option('noseed');

if ($max < 1) {
$max = null;
Expand Down Expand Up @@ -107,7 +108,8 @@ public function fire()
$dumpAuto,
$indexed,
$orderBy,
$direction
$direction,
$seeded
),
$table
);
Expand Down