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

Laravel 9 update #369

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
],
"require": {
"php": ">=7.4",
"illuminate/container": "^8.0",
"illuminate/contracts": "^8.0",
"illuminate/database": "^8.0",
"illuminate/events": "^8.0",
"illuminate/support": "^8.0",
"illuminate/pagination": "^8.0",
"nesbot/carbon": "^2.0",
"illuminate/container": "^9.0",
"illuminate/contracts": "^9.0",
"illuminate/database": "^9.0",
"illuminate/events": "^9.0",
"illuminate/support": "^9.0",
"illuminate/pagination": "^9.0",
"nesbot/carbon": "^2.5",
"laudis/neo4j-php-client": "^2.3.3"
},
"require-dev": {
Expand Down
20 changes: 0 additions & 20 deletions src/Console/Migrations/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@ protected function getMigrationPath()
return $this->laravel['path.base'].'/'.$path;
}

$package = $this->input->getOption('package');

// If the package is in the list of migration paths we received we will put
// the migrations in that path. Otherwise, we will assume the package is
// is in the package directories and will place them in that location.
if (!is_null($package)) {
return $this->packagePath.'/'.$package.'/src/'.self::LABELS_DIRECTORY;
}

$bench = $this->input->getOption('bench');

// Finally we will check for the workbench option, which is a shortcut into
// specifying the full path for a "workbench" project. Workbenches allow
// developers to develop packages along side a "standard" app install.
if (!is_null($bench)) {
$path = "/workbench/{$bench}/src/".self::LABELS_DIRECTORY;

return $this->laravel['path.base'].$path;
}

return $this->laravel['path.database'].'/'.self::LABELS_DIRECTORY;
}
}
67 changes: 30 additions & 37 deletions src/Console/Migrations/MigrateMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

class MigrateMakeCommand extends BaseCommand
{
/**
* {@inheritDoc}
*/
protected $name = 'neo4j:make:migration';

/**
* {@inheritDoc}
*/
protected $signature = 'neo4j:make:migration {name : The name of the migration}
{--create= : The table to be created}
{--label= : The table to migrate}
{--path= : The location where the migration file should be created}
{--realpath : Indicate any provided migration file paths are pre-resolved absolute paths}
{--fullpath : Output the full path of the migration}';


protected $description = 'Create a new migration file';

/**
Expand Down Expand Up @@ -49,19 +50,13 @@ public function __construct(MigrationCreator $creator, Composer $composer, $pack
$this->composer = $composer;
}

/**
* {@inheritDoc}
*/
public function fire()
public function handle()
{
// It's possible for the developer to specify the tables to modify in this
// schema operation. The developer may also specify if this label needs
// to be freshly created so we can create the appropriate migrations.
$name = $this->input->getArgument('name');

$label = $this->input->getOption('label');

$modify = $this->input->getOption('create');
$modify = $this->input->getOption('create') ?? false;

if (!$label && is_string($modify)) {
$label = $modify;
Expand All @@ -70,7 +65,7 @@ public function fire()
// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $label);
$this->writeMigration($name, $label, $modify);

$this->composer->dumpAutoloads();
}
Expand All @@ -84,40 +79,38 @@ public function fire()
*
* @return string
*/
protected function writeMigration($name, $label)
protected function writeMigration(string $name, ?string $label, bool $modify)
{
$path = $this->getMigrationPath();
$file = pathinfo($this->creator->create(
$name, $this->getMigrationPath(), $label, $modify
), PATHINFO_FILENAME);

$file = pathinfo($this->creator->create($name, $path, $label), PATHINFO_FILENAME);
$this->components->info(sprintf('Created migration [%s].', $file));
}

protected function getMigrationPath(): string
{
if (! is_null($targetPath = $this->input->getOption('path'))) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$targetPath
: $targetPath;
}

$this->line("<info>Created Migration:</info> $file");
return parent::getMigrationPath();
}

/**
* {@inheritDoc}
*/
protected function getArguments()
protected function usingRealPath(): bool
{
return array(
array('name', InputArgument::REQUIRED, 'The name of the migration'),
);
return $this->input->hasOption('realpath') && $this->option('realpath');
}

/**
* {@inheritDoc}
*/
protected function getOptions()
protected function getArguments()
{
return array(
array('bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the migration belongs to.', null),

array('create', null, InputOption::VALUE_OPTIONAL, 'The label schema to be created.'),

array('package', null, InputOption::VALUE_OPTIONAL, 'The package the migration belongs to.', null),

array('path', null, InputOption::VALUE_OPTIONAL, 'Where to store the migration.', null),

array('label', null, InputOption::VALUE_OPTIONAL, 'The label to migrate.'),
array('name', InputArgument::REQUIRED, 'The name of the migration'),
);
}
}
5 changes: 2 additions & 3 deletions src/Migrations/MigrationCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ class MigrationCreator extends IlluminateMigrationCreator
/**
* Populate the place-holders in the migration stub.
*
* @param string $name
* @param string $stub
* @param string $label
*
* @return string
*/
protected function populateStub($name, $stub, $label)
protected function populateStub($stub, $label)
{
$stub = str_replace('{{class}}', studly_case($name), $stub);
$stub = str_replace('{{class}}', $this->getClassName($stub), $stub);

// Here we will replace the label place-holders with the label specified by
// the developer, which is useful for quickly creating a labels creation
Expand Down