From 814fac89c4169b3b69a9fc0cb82a9f102aa8e9e6 Mon Sep 17 00:00:00 2001 From: Jon Nott Date: Fri, 22 Mar 2024 22:19:13 +0000 Subject: [PATCH] drop dependency on abandoned package laravelcollective/html - move columnSort() into helpers.php and return HtmlString object directly, and drop TotemFormServiceProvider - replace Form::{method}() calls with manual form markup - update TestCase accordingly --- composer.json | 8 ++-- resources/views/tasks/index.blade.php | 29 +++++++----- src/Providers/TotemFormServiceProvider.php | 55 ---------------------- src/Providers/TotemServiceProvider.php | 1 - src/helpers.php | 45 ++++++++++++++++++ tests/TestCase.php | 16 +------ 6 files changed, 69 insertions(+), 85 deletions(-) delete mode 100644 src/Providers/TotemFormServiceProvider.php create mode 100644 src/helpers.php diff --git a/composer.json b/composer.json index aa1eec17..4259b1b8 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,7 @@ "illuminate/contracts": "^9.0|^10.0", "illuminate/database": "^9.0|^10.0", "illuminate/events": "^9.0|^10.0", - "illuminate/notifications": "^9.0|^10.0", - "laravelcollective/html": "^6.0" + "illuminate/notifications": "^9.0|^10.0" }, "require-dev": { "mockery/mockery": "^1.0", @@ -40,7 +39,10 @@ "Studio\\Totem\\": "src/", "Studio\\Totem\\Tests\\": "tests/", "Database\\Factories\\": "database/factories/" - } + }, + "files": [ + "src/helpers.php" + ] }, "extra": { "component": "package", diff --git a/resources/views/tasks/index.blade.php b/resources/views/tasks/index.blade.php index 12f80327..cd34ff8d 100644 --- a/resources/views/tasks/index.blade.php +++ b/resources/views/tasks/index.blade.php @@ -6,24 +6,29 @@ @section('title')

Tasks

- {!! Form::open([ - 'id' => 'totem__search__form', - 'url' => Request::fullUrl(), - 'method' => 'GET', - 'class' => 'uk-display-inline uk-search uk-search-default' - ]) !!} - - {!! Form::text('q', request('q'), ['class' => 'uk-search-input', 'placeholder' => 'Search...']) !!} - {!! Form::close() !!} +
@stop @section('main-panel-content') - - - + + + diff --git a/src/Providers/TotemFormServiceProvider.php b/src/Providers/TotemFormServiceProvider.php deleted file mode 100644 index c20095c4..00000000 --- a/src/Providers/TotemFormServiceProvider.php +++ /dev/null @@ -1,55 +0,0 @@ -app['html']->macro('columnSort', function (string $label, string $columnKey, bool $isDefault = false) { - $icon = ''; - - if (request()->has('sort_by')) { - if (request()->input('sort_by') == $columnKey) { - $icon = ' '; - } - } elseif ($isDefault) { - $icon = ' '; - } - - $order = 'asc'; - if (request()->has('sort_direction')) { - $order = (request()->input('sort_direction') == 'desc' ? 'asc' : 'desc'); - } elseif ($isDefault) { - $order = 'desc'; - } - - $url = request()->fullUrlWithQuery([ - 'sort_by' => $columnKey, - 'sort_direction' => $order, - 'filter' => request('filter'), - 'limit' => request('limit'), - ]); - - return app('html')->toHtmlString( - '' - .$label - .$icon - .'' - ); - }); - } -} diff --git a/src/Providers/TotemServiceProvider.php b/src/Providers/TotemServiceProvider.php index 87bceac6..f3139c78 100644 --- a/src/Providers/TotemServiceProvider.php +++ b/src/Providers/TotemServiceProvider.php @@ -65,7 +65,6 @@ public function register() $this->app->alias('totem.tasks', TaskInterface::class); $this->app->register(TotemRouteServiceProvider::class); $this->app->register(TotemEventServiceProvider::class); - $this->app->register(TotemFormServiceProvider::class); $this->app->register(ConsoleServiceProvider::class); } diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 00000000..6d7e2e0f --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,45 @@ +has('sort_by')) { + if (request()->input('sort_by') == $columnKey) { + $icon = ' '; + } + } elseif ($isDefault) { + $icon = ' '; + } + + $order = 'asc'; + if (request()->has('sort_direction')) { + $order = (request()->input('sort_direction') == 'desc' ? 'asc' : 'desc'); + } elseif ($isDefault) { + $order = 'desc'; + } + + $url = request()->fullUrlWithQuery([ + 'sort_by' => $columnKey, + 'sort_direction' => $order, + 'filter' => request('filter'), + 'limit' => request('limit'), + ]); + + return new HtmlString( + '' + .$label + .$icon + .'' + ); +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 1ea0acf2..2700020a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,6 @@ namespace Studio\Totem\Tests; -use Collective\Html\FormFacade; -use Collective\Html\HtmlFacade; -use Collective\Html\HtmlServiceProvider; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Support\Facades\Auth; use Orchestra\Testbench\Exceptions\Handler; @@ -47,25 +44,16 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('database.default', 'testing'); $app['config']->set('database.connections.testing', [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => '', + 'prefix' => '', ]); } - protected function getPackageAliases($app) - { - return [ - 'Form' => FormFacade::class, - 'Html' => HtmlFacade::class, - ]; - } - protected function getPackageProviders($app) { return [ TotemServiceProvider::class, - HtmlServiceProvider::class, ]; }
{!! Html::columnSort('Description', 'description') !!}{!! Html::columnSort('Average Runtime', 'average_runtime') !!}{!! Html::columnSort('Last Run', 'last_ran_at') !!}{!! \Studio\Totem\Helpers\columnSort('Description', 'description') !!}{!! \Studio\Totem\Helpers\columnSort('Average Runtime', 'average_runtime') !!}{!! \Studio\Totem\Helpers\columnSort('Last Run', 'last_ran_at') !!} Next Run Execute