Skip to content

Commit 1559b63

Browse files
committed
build: drop collective html dependency
1 parent f013526 commit 1559b63

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"require": {
1919
"php": "^8.1",
2020
"ext-json": "*",
21-
"yajra/laravel-datatables-oracle": "^10.0",
22-
"laravelcollective/html": "^6.3.0"
21+
"yajra/laravel-datatables-oracle": "^10.0"
2322
},
2423
"require-dev": {
2524
"nunomaduro/larastan": "^2.4",

src/Html/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Yajra\DataTables\Html;
44

5-
use Collective\Html\HtmlBuilder;
5+
use Yajra\DataTables\Html\HtmlBuilder;
66
use Illuminate\Contracts\Config\Repository;
77
use Illuminate\Contracts\View\Factory;
88
use Illuminate\Support\Collection;

src/Html/HtmlBuilder.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Yajra\DataTables\Html;
4+
5+
class HtmlBuilder
6+
{
7+
public function attributes(array $attributes): string
8+
{
9+
$html = [];
10+
foreach ($attributes as $key => $value) {
11+
$element = $this->attributeElement($key, $value);
12+
if (! is_null($element)) {
13+
$html[] = $element;
14+
}
15+
}
16+
17+
return count($html) > 0 ? ' '.implode(' ', $html) : '';
18+
}
19+
20+
private function attributeElement(int|string $key, mixed $value): ?string
21+
{
22+
if (is_numeric($key)) {
23+
$key = $value;
24+
}
25+
26+
if (! is_null($value)) {
27+
return $key.'="'.e($value).'"';
28+
}
29+
30+
return null;
31+
}
32+
}

src/HtmlServiceProvider.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Yajra\DataTables;
44

5-
use Collective\Html\HtmlServiceProvider as CollectiveHtml;
65
use Illuminate\Support\ServiceProvider;
76

87
class HtmlServiceProvider extends ServiceProvider
@@ -41,8 +40,6 @@ public function register(): void
4140
{
4241
$this->mergeConfigFrom(__DIR__.'/resources/config/config.php', 'datatables-html');
4342

44-
$this->app->register(CollectiveHtml::class);
45-
4643
$this->app->bind('datatables.html', function () {
4744
return $this->app->make(Html\Builder::class);
4845
});

0 commit comments

Comments
 (0)