Skip to content

Commit 833cbbe

Browse files
committed
Merge branch 'develop'
2 parents 94782c4 + 9f77c7e commit 833cbbe

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [0.1.4] - 2020-05-24
8+
9+
### Changed
10+
11+
- Changed $models to $builder
12+
- Changed callback parameters for sorting to $builder, $direction. (Removed sortField because we know what it is, until someone gives me an example of why it would be beneficial to keep it).
13+
714
## [0.1.3] - 2020-05-12
815

916
### Changed
@@ -27,7 +34,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
2734

2835
- Initial release
2936

30-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...development
37+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.4...development
38+
[0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4
3139
[0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3
3240
[0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2
3341
[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Of course two links that don't do anything would be useless, here are a list of
340340
| hide() | Hide this component forever |
341341
| isHidden() | This component is currently hidden |
342342

343-
By default all components have access to the `$attributes` and `$options` arrays.
343+
By default, all components have access to the `$attributes` and `$options` arrays.
344344

345345
#### Link Component
346346

src/TableComponent.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,22 @@ public function render(): View
102102
*/
103103
public function models(): Builder
104104
{
105-
$models = $this->query();
105+
$builder = $this->query();
106106

107107
if ($this->searchEnabled && trim($this->search) !== '') {
108-
$models->where(function (Builder $query) {
108+
$builder->where(function (Builder $builder) {
109109
foreach ($this->columns() as $column) {
110110
if ($column->searchable) {
111111
if (is_callable($column->searchCallback)) {
112-
$query = app()->call($column->searchCallback, ['builder' => $query, 'term' => $this->search]);
112+
$builder = app()->call($column->searchCallback, ['builder' => $builder, 'term' => $this->search]);
113113
} elseif (Str::contains($column->attribute, '.')) {
114114
$relationship = $this->relationship($column->attribute);
115115

116-
$query->orWhereHas($relationship->name, function (Builder $query) use ($relationship) {
117-
$query->where($relationship->attribute, 'like', '%'.$this->search.'%');
116+
$builder->orWhereHas($relationship->name, function (Builder $builder) use ($relationship) {
117+
$builder->where($relationship->attribute, 'like', '%'.$this->search.'%');
118118
});
119119
} else {
120-
$query->orWhere($query->getModel()->getTable().'.'.$column->attribute, 'like', '%'.$this->search.'%');
120+
$builder->orWhere($builder->getModel()->getTable().'.'.$column->attribute, 'like', '%'.$this->search.'%');
121121
}
122122
}
123123
}
@@ -126,15 +126,15 @@ public function models(): Builder
126126

127127
if (Str::contains($this->sortField, '.')) {
128128
$relationship = $this->relationship($this->sortField);
129-
$sortField = $this->attribute($models, $relationship->name, $relationship->attribute);
129+
$sortField = $this->attribute($builder, $relationship->name, $relationship->attribute);
130130
} else {
131131
$sortField = $this->sortField;
132132
}
133133

134134
if (($column = $this->getColumnByAttribute($this->sortField)) !== null && is_callable($column->sortCallback)) {
135-
return app()->call($column->sortCallback, ['models' => $models, 'sortField' => $sortField, 'sortDirection' => $this->sortDirection]);
135+
return app()->call($column->sortCallback, ['builder' => $builder, 'direction' => $this->sortDirection]);
136136
}
137137

138-
return $models->orderBy($sortField, $this->sortDirection);
138+
return $builder->orderBy($sortField, $this->sortDirection);
139139
}
140140
}

0 commit comments

Comments
 (0)