Example #1
0
 /**
  * Seed the given connection from the given path.
  *
  * @param  Illuminate\Database\Connection  $connection
  * @param  string  $path
  * @return int
  */
 public function seed(Connection $connection, $path)
 {
     $total = 0;
     foreach ($this->getFiles($path) as $file) {
         $records = $this->files->getRequire($file);
         // We'll grab the table name here, which could either come from the array or
         // from the filename itself. Then, we will simply insert the records into
         // the databases via a connection and fire an event noting the seeding.
         $table = $this->getTable($records, $file);
         $connection->table($table)->delete();
         $connection->table($table)->insert($records);
         $total += $count = count($records);
         // Once we have seeded the table, we will fire an event to let any listeners
         // know the tables have been seeded and how many records were inserted so
         // information can be presented to the developer about the seeding run.
         if (isset($this->events)) {
             $this->events->fire('illuminate.seeding', array($table, $count));
         }
     }
     return $total;
 }
 /**
  * Get a file's contents by requiring it.
  *
  * @param  string  $path
  * @return mixed
  */
 protected function getRequire($path)
 {
     return $this->files->getRequire($path);
 }
 /**
  * Load a locale from a given path.
  *
  * @param  string  $path
  * @param  string  $locale
  * @param  string  $group
  * @return array
  */
 protected function loadPath($path, $locale, $group)
 {
     if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
         return array_dot($this->files->getRequire($full));
     }
     return array();
 }