diff --git a/src/Orangehill/Iseed/Iseed.php b/src/Orangehill/Iseed/Iseed.php index 3a3f40d..5b7ae45 100644 --- a/src/Orangehill/Iseed/Iseed.php +++ b/src/Orangehill/Iseed/Iseed.php @@ -61,7 +61,7 @@ public function readStubFile($file) * @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', $whereClause = null) { if (!$database) { $database = config('database.default'); @@ -75,7 +75,7 @@ public function generateSeed($table, $prefix=null, $suffix=null, $database = nul } // Get the data - $data = $this->getData($table, $max, $exclude, $orderBy, $direction); + $data = $this->getData($table, $max, $exclude, $orderBy, $direction, $whereClause); // Repack the data $dataArray = $this->repackSeedData($data); @@ -130,7 +130,7 @@ public function getSeedPath() * @param string $table * @return Array */ - public function getData($table, $max, $exclude = null, $orderBy = null, $direction = 'ASC') + public function getData($table, $max, $exclude = null, $orderBy = null, $direction = 'ASC', $whereClause = null) { $result = \DB::connection($this->databaseName)->table($table); @@ -139,6 +139,10 @@ public function getData($table, $max, $exclude = null, $orderBy = null, $directi $result = $result->select(array_diff($allColumns, $exclude)); } + if ($whereClause) { + $result = $result->whereRaw($whereClause); + } + if($orderBy) { $result = $result->orderBy($orderBy, $direction); }