mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Format code.
This commit is contained in:
parent
90b3fbd0a5
commit
d32357a788
@ -88,4 +88,4 @@ class GenSeederCommand extends BaseCommand
|
||||
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided seeder file paths are pre-resolved absolute paths'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,4 +85,4 @@ class SeedCommand extends BaseCommand
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user