Skip to content

Commit 814fac8

Browse files
committed
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
1 parent e98011d commit 814fac8

File tree

6 files changed

+69
-85
lines changed

6 files changed

+69
-85
lines changed

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"illuminate/contracts": "^9.0|^10.0",
2525
"illuminate/database": "^9.0|^10.0",
2626
"illuminate/events": "^9.0|^10.0",
27-
"illuminate/notifications": "^9.0|^10.0",
28-
"laravelcollective/html": "^6.0"
27+
"illuminate/notifications": "^9.0|^10.0"
2928
},
3029
"require-dev": {
3130
"mockery/mockery": "^1.0",
@@ -40,7 +39,10 @@
4039
"Studio\\Totem\\": "src/",
4140
"Studio\\Totem\\Tests\\": "tests/",
4241
"Database\\Factories\\": "database/factories/"
43-
}
42+
},
43+
"files": [
44+
"src/helpers.php"
45+
]
4446
},
4547
"extra": {
4648
"component": "package",

resources/views/tasks/index.blade.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,29 @@
66
@section('title')
77
<div class="uk-flex uk-flex-between uk-flex-middle">
88
<h4 class="uk-card-title uk-margin-remove">Tasks</h4>
9-
{!! Form::open([
10-
'id' => 'totem__search__form',
11-
'url' => Request::fullUrl(),
12-
'method' => 'GET',
13-
'class' => 'uk-display-inline uk-search uk-search-default'
14-
]) !!}
15-
<span uk-search-icon></span>
16-
{!! Form::text('q', request('q'), ['class' => 'uk-search-input', 'placeholder' => 'Search...']) !!}
17-
{!! Form::close() !!}
9+
<form
10+
accept-charset="UTF-8"
11+
method="GET"
12+
action="{{ request()->fullUrl() }}"
13+
id="totem__search__form"
14+
class="uk-display-inline uk-search uk-search-default">
15+
<span uk-search-icon></span>
16+
<input
17+
value="{{ request('q') }}"
18+
placeholder="Search..."
19+
name="q"
20+
type="text"
21+
class="uk-search-input">
22+
</form>
1823
</div>
1924
@stop
2025
@section('main-panel-content')
2126
<table class="uk-table uk-table-responsive" cellpadding="0" cellspacing="0" class="mb1">
2227
<thead>
2328
<tr>
24-
<th>{!! Html::columnSort('Description', 'description') !!}</th>
25-
<th>{!! Html::columnSort('Average Runtime', 'average_runtime') !!}</th>
26-
<th>{!! Html::columnSort('Last Run', 'last_ran_at') !!}</th>
29+
<th>{!! \Studio\Totem\Helpers\columnSort('Description', 'description') !!}</th>
30+
<th>{!! \Studio\Totem\Helpers\columnSort('Average Runtime', 'average_runtime') !!}</th>
31+
<th>{!! \Studio\Totem\Helpers\columnSort('Last Run', 'last_ran_at') !!}</th>
2732
<th>Next Run</th>
2833
<th class="uk-text-center">Execute</th>
2934
</tr>

src/Providers/TotemFormServiceProvider.php

-55
This file was deleted.

src/Providers/TotemServiceProvider.php

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public function register()
6565
$this->app->alias('totem.tasks', TaskInterface::class);
6666
$this->app->register(TotemRouteServiceProvider::class);
6767
$this->app->register(TotemEventServiceProvider::class);
68-
$this->app->register(TotemFormServiceProvider::class);
6968
$this->app->register(ConsoleServiceProvider::class);
7069
}
7170

src/helpers.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace Studio\Totem\Helpers;
4+
5+
use Illuminate\Support\HtmlString;
6+
7+
function columnSort(string $label, string $columnKey, bool $isDefault = false)
8+
{
9+
$icon = '';
10+
11+
if (request()->has('sort_by')) {
12+
if (request()->input('sort_by') == $columnKey) {
13+
$icon = ' <span class="fa fa-caret-'
14+
.(request()->input('sort_direction', 'asc') == 'asc' ? 'up' : 'down')
15+
.'"></span>';
16+
}
17+
} elseif ($isDefault) {
18+
$icon = ' <span class="fa fa-caret-'
19+
.(request()->input('sort_direction', 'asc') == 'asc' ? 'up' : 'down')
20+
.'"></span>';
21+
}
22+
23+
$order = 'asc';
24+
if (request()->has('sort_direction')) {
25+
$order = (request()->input('sort_direction') == 'desc' ? 'asc' : 'desc');
26+
} elseif ($isDefault) {
27+
$order = 'desc';
28+
}
29+
30+
$url = request()->fullUrlWithQuery([
31+
'sort_by' => $columnKey,
32+
'sort_direction' => $order,
33+
'filter' => request('filter'),
34+
'limit' => request('limit'),
35+
]);
36+
37+
return new HtmlString(
38+
'<a href="'
39+
.$url
40+
.'">'
41+
.$label
42+
.$icon
43+
.'</a>'
44+
);
45+
}

tests/TestCase.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace Studio\Totem\Tests;
44

5-
use Collective\Html\FormFacade;
6-
use Collective\Html\HtmlFacade;
7-
use Collective\Html\HtmlServiceProvider;
85
use Illuminate\Contracts\Debug\ExceptionHandler;
96
use Illuminate\Support\Facades\Auth;
107
use Orchestra\Testbench\Exceptions\Handler;
@@ -47,25 +44,16 @@ protected function getEnvironmentSetUp($app)
4744
{
4845
$app['config']->set('database.default', 'testing');
4946
$app['config']->set('database.connections.testing', [
50-
'driver' => 'sqlite',
47+
'driver' => 'sqlite',
5148
'database' => ':memory:',
52-
'prefix' => '',
49+
'prefix' => '',
5350
]);
5451
}
5552

56-
protected function getPackageAliases($app)
57-
{
58-
return [
59-
'Form' => FormFacade::class,
60-
'Html' => HtmlFacade::class,
61-
];
62-
}
63-
6453
protected function getPackageProviders($app)
6554
{
6655
return [
6756
TotemServiceProvider::class,
68-
HtmlServiceProvider::class,
6957
];
7058
}
7159

0 commit comments

Comments
 (0)