Skip to content

Commit ab1430a

Browse files
committed
- Cleanup
1 parent cb9bbd7 commit ab1430a

File tree

5 files changed

+11
-36
lines changed

5 files changed

+11
-36
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

3-
All notable changes to `livewire-tables` will be documented in this file
3+
All notable changes to `laravel-livewire-tables` will be documented in this file
44

5-
## 1.0.0 - 2020-03-23
5+
## 1.0.0 - 2020-XX-XX
66

77
- Initial release

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^7.2.5",
23-
"illuminate/support": "^6.0|^7.0"
22+
"php": "^7.2.5"
2423
},
2524
"require-dev": {
2625
"livewire/livewire": "^1.0",
27-
"orchestra/testbench": "^4.0|^5.0",
2826
"phpunit/phpunit": "^8.0|^9.0"
2927
},
3028
"autoload": {

config/laravel-livewire-tables.php

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

src/Http/Livewire/TableComponent.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,20 @@ public function models() : Builder
104104
{
105105
$models = $this->query();
106106

107-
if ($this->searchEnabled && $this->search) {
107+
if ($this->searchEnabled && trim($this->search) !== '') {
108108
$models->where(function (Builder $query) {
109109
foreach ($this->columns() as $column) {
110110
if ($column->searchable) {
111111
if (is_callable($column->searchCallback)) {
112112
$query = app()->call($column->searchCallback, ['builder' => $query, 'term' => $this->search]);
113+
} elseif (Str::contains($column->attribute, '.')) {
114+
$relationship = $this->relationship($column->attribute);
115+
116+
$query->orWhereHas($relationship->name, function (Builder $query) use ($relationship) {
117+
$query->where($relationship->attribute, 'like', '%' . $this->search . '%');
118+
});
113119
} else {
114-
if (Str::contains($column->attribute, '.')) {
115-
$relationship = $this->relationship($column->attribute);
116-
117-
$query->orWhereHas($relationship->name, function (Builder $query) use ($relationship) {
118-
$query->where($relationship->attribute, 'like', '%' . $this->search . '%');
119-
});
120-
} else {
121-
$query->orWhere($query->getModel()->getTable() . '.' . $column->attribute, 'like', '%' . $this->search . '%');
122-
}
120+
$query->orWhere($query->getModel()->getTable() . '.' . $column->attribute, 'like', '%' . $this->search . '%');
123121
}
124122
}
125123
}

src/LivewireTablesServiceProvider.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,6 @@ class LivewireTablesServiceProvider extends ServiceProvider
1515
*/
1616
public function boot()
1717
{
18-
if ($this->app->runningInConsole()) {
19-
$this->publishes([
20-
__DIR__.'/../config/laravel-livewire-tables.php' => config_path('laravel-livewire-tables.php'),
21-
], 'config');
22-
}
23-
2418
$this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-livewire-tables');
2519
}
26-
27-
/**
28-
* Register the application services.
29-
*/
30-
public function register()
31-
{
32-
// Register the config file
33-
$this->mergeConfigFrom(__DIR__.'/../config/laravel-livewire-tables.php', 'laravel-livewire-tables');
34-
}
3520
}

0 commit comments

Comments
 (0)