Format code.

This commit is contained in:
李铭昕 2019-09-27 14:34:48 +08:00
parent 90b3fbd0a5
commit d32357a788
5 changed files with 39 additions and 43 deletions

View File

@ -88,4 +88,4 @@ class GenSeederCommand extends BaseCommand
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided seeder file paths are pre-resolved absolute paths'],
];
}
}
}

View File

@ -85,4 +85,4 @@ class SeedCommand extends BaseCommand
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
];
}
}
}

View File

@ -182,13 +182,13 @@ class Seed
/**
* Get all of the seeder files in a given path.
*
* @param string|array $paths
* @param array|string $paths
* @return array
*/
public function getSeederFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*.php');
return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path . '/*.php');
})->filter()->sortBy(function ($file) {
return $this->getSeederName($file);
})->values()->keyBy(function ($file) {
@ -253,8 +253,7 @@ class Seed
/**
* Write a note to the console's output.
*
* @param string $message
* @return void
* @param string $message
*/
protected function note($message)
{
@ -262,4 +261,4 @@ class Seed
$this->output->writeln($message);
}
}
}
}

View File

@ -12,17 +12,8 @@ declare(strict_types=1);
namespace Hyperf\Database\Seeders;
use InvalidArgumentException;
abstract class Seeder
{
/**
* The name of the database connection to use.
*
* @var string|null
*/
protected $connection = 'default';
/**
* Enables, if supported, wrapping the seeder within a transaction.
*
@ -30,13 +21,20 @@ abstract class Seeder
*/
public $withinTransaction = true;
/**
* The name of the database connection to use.
*
* @var null|string
*/
protected $connection = 'default';
/**
* Get the seeder connection name.
*
* @return string|null
* @return null|string
*/
public function getConnection()
{
return $this->connection;
}
}
}

View File

@ -56,6 +56,26 @@ class SeederCreator
return $path;
}
/**
* Get the path to the stubs.
*
* @return string
*/
public function stubPath()
{
return __DIR__ . '/stubs';
}
/**
* Get the filesystem instance.
*
* @return \Hyperf\Utils\Filesystem\Filesystem
*/
public function getFilesystem()
{
return $this->files;
}
/**
* Get the seeder stub file.
*
@ -63,7 +83,7 @@ class SeederCreator
*/
protected function getStub()
{
return $this->files->get($this->stubPath().'/seeder.stub');
return $this->files->get($this->stubPath() . '/seeder.stub');
}
/**
@ -82,7 +102,6 @@ class SeederCreator
* Ensure that a seeder with the given name doesn't already exist.
*
* @param string $name
* @return void
*
* @throws \InvalidArgumentException
*/
@ -96,7 +115,7 @@ class SeederCreator
/**
* Get the class name of a seeder name.
*
* @param string $name
* @param string $name
* @return string
*/
protected function getClassName($name)
@ -113,26 +132,6 @@ class SeederCreator
*/
protected function getPath($name, $path)
{
return $path.'/'.$name.'.php';
return $path . '/' . $name . '.php';
}
/**
* Get the path to the stubs.
*
* @return string
*/
public function stubPath()
{
return __DIR__.'/stubs';
}
/**
* Get the filesystem instance.
*
* @return \Hyperf\Utils\Filesystem\Filesystem
*/
public function getFilesystem()
{
return $this->files;
}
}
}