Skip to content

Commit 2ef3787

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 2ef3787

File tree

6 files changed

+65
-83
lines changed

6 files changed

+65
-83
lines changed

composer.json

Lines changed: 5 additions & 3 deletions
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

Lines changed: 17 additions & 12 deletions
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

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/Providers/TotemServiceProvider.php

Lines changed: 0 additions & 1 deletion
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

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

tests/TestCase.php

Lines changed: 0 additions & 12 deletions
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;
@@ -53,19 +50,10 @@ protected function getEnvironmentSetUp($app)
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)