From 786468c822548e543ae48fcdaed0ee7e9f446981 Mon Sep 17 00:00:00 2001 From: Jeremiah Fulbright Date: Thu, 10 Sep 2020 13:04:34 -0500 Subject: [PATCH] port changes for laravel 6+ --- .../ClosureTableServiceProvider.php | 20 +--------- .../Console/ClosureTableCommand.php | 39 ------------------- .../ClosureTable/Console/MakeCommand.php | 12 +++--- src/Franzose/ClosureTable/Extensions/Str.php | 4 +- src/Franzose/ClosureTable/Models/Entity.php | 3 +- 5 files changed, 10 insertions(+), 68 deletions(-) delete mode 100644 src/Franzose/ClosureTable/Console/ClosureTableCommand.php diff --git a/src/Franzose/ClosureTable/ClosureTableServiceProvider.php b/src/Franzose/ClosureTable/ClosureTableServiceProvider.php index b4fb691..5744e66 100644 --- a/src/Franzose/ClosureTable/ClosureTableServiceProvider.php +++ b/src/Franzose/ClosureTable/ClosureTableServiceProvider.php @@ -2,7 +2,6 @@ namespace Franzose\ClosureTable; use Illuminate\Support\ServiceProvider; -use Franzose\ClosureTable\Console\ClosureTableCommand; use Franzose\ClosureTable\Console\MakeCommand; /** @@ -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. * @@ -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'); } /** diff --git a/src/Franzose/ClosureTable/Console/ClosureTableCommand.php b/src/Franzose/ClosureTable/Console/ClosureTableCommand.php deleted file mode 100644 index 072bec6..0000000 --- a/src/Franzose/ClosureTable/Console/ClosureTableCommand.php +++ /dev/null @@ -1,39 +0,0 @@ -info('ClosureTable v' . CT::VERSION); - $this->line('Closure Table database design pattern implementation for Laravel framework.'); - $this->comment('Copyright (c) 2013-2014 Jan Iwanow'); - } -} diff --git a/src/Franzose/ClosureTable/Console/MakeCommand.php b/src/Franzose/ClosureTable/Console/MakeCommand.php index 5d102ef..560ef82 100644 --- a/src/Franzose/ClosureTable/Console/MakeCommand.php +++ b/src/Franzose/ClosureTable/Console/MakeCommand.php @@ -1,13 +1,13 @@ 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'; diff --git a/src/Franzose/ClosureTable/Extensions/Str.php b/src/Franzose/ClosureTable/Extensions/Str.php index f94b8b5..57a6981 100644 --- a/src/Franzose/ClosureTable/Extensions/Str.php +++ b/src/Franzose/ClosureTable/Extensions/Str.php @@ -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)); } /** @@ -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))); } } diff --git a/src/Franzose/ClosureTable/Models/Entity.php b/src/Franzose/ClosureTable/Models/Entity.php index 68f8a86..5e88d13 100644 --- a/src/Franzose/ClosureTable/Models/Entity.php +++ b/src/Franzose/ClosureTable/Models/Entity.php @@ -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. @@ -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