Skip to content

Commit

Permalink
port changes for laravel 6+
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fulbright committed Sep 10, 2020
1 parent c590309 commit 786468c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 68 deletions.
20 changes: 1 addition & 19 deletions src/Franzose/ClosureTable/ClosureTableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Franzose\ClosureTable;

use Illuminate\Support\ServiceProvider;
use Franzose\ClosureTable\Console\ClosureTableCommand;
use Franzose\ClosureTable\Console\MakeCommand;

/**
Expand All @@ -12,19 +11,6 @@
*/
class ClosureTableServiceProvider extends ServiceProvider
{

/**
* Current library version
*/
const VERSION = 4;

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
Expand All @@ -42,15 +28,11 @@ public function boot()
public function register()
{
// Here we register commands for artisan
$this->app->singleton('command.closuretable', function ($app) {
return new ClosureTableCommand;
});

$this->app->singleton('command.closuretable.make', function ($app) {
return $app['Franzose\ClosureTable\Console\MakeCommand'];
});

$this->commands('command.closuretable', 'command.closuretable.make');
$this->commands('command.closuretable.make');
}

/**
Expand Down
39 changes: 0 additions & 39 deletions src/Franzose/ClosureTable/Console/ClosureTableCommand.php

This file was deleted.

12 changes: 5 additions & 7 deletions src/Franzose/ClosureTable/Console/MakeCommand.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
namespace Franzose\ClosureTable\Console;

use Illuminate\Console\DetectsApplicationNamespace;
use Franzose\ClosureTable\Extensions\Str as ExtStr;
use Franzose\ClosureTable\Generators\Migration;
use Franzose\ClosureTable\Generators\Model;
use Illuminate\Console\Command;
use Illuminate\Container\Container;
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputOption;
use Franzose\ClosureTable\Generators\Migration;
use Franzose\ClosureTable\Generators\Model;
use Franzose\ClosureTable\Extensions\Str as ExtStr;

/**
* ClosureTable scaffolding command, created migrations and models.
Expand All @@ -16,8 +16,6 @@
*/
class MakeCommand extends Command
{
use DetectsApplicationNamespace;

/**
* The console command name.
*
Expand Down Expand Up @@ -152,7 +150,7 @@ protected function prepareOptions()

$lastnsdelim = strrpos($input[1], '\\');

$this->options[$options[0][0]] = $input[0] ?: rtrim($this->getAppNamespace(), '\\');
$this->options[$options[0][0]] = $input[0] ?: rtrim(Container::getInstance()->getNamespace(), '\\');
$this->options[$options[1][0]] = substr($input[1], $lastnsdelim);
$this->options[$options[2][0]] = $input[2] ?: ExtStr::tableize($input[1]);
$this->options[$options[3][0]] = $input[3] ?: $this->options[$options[1][0]] . 'Closure';
Expand Down
4 changes: 2 additions & 2 deletions src/Franzose/ClosureTable/Extensions/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Str extends BaseStr
*/
public static function classify($name)
{
return studly_case(str_singular($name));
return static::studely(static::singular($name));
}

/**
Expand All @@ -31,6 +31,6 @@ public static function tableize($name)
{
$name = str_replace('\\', '', $name);

return (ends_with($name, 'Closure') ? snake_case($name) : snake_case(str_plural($name)));
return (static::endsWith($name, 'Closure') ? static::snake($name) : static::snake(static::plural($name)));
}
}
3 changes: 2 additions & 1 deletion src/Franzose/ClosureTable/Models/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Franzose\ClosureTable\Extensions\QueryBuilder;
use Franzose\ClosureTable\Contracts\EntityInterface;
use Franzose\ClosureTable\Extensions\Collection;
use Illuminate\Support\Arr;

/**
* Basic entity class.
Expand Down Expand Up @@ -1202,7 +1203,7 @@ public static function createFromArray(array $tree, EntityInterface $parent = nu
$entities = [];

foreach ($tree as $item) {
$children = array_pull($item, $childrenRelationIndex);
$children = Arr::pull($item, $childrenRelationIndex);

/**
* @var Entity $entity
Expand Down

0 comments on commit 786468c

Please sign in to comment.