Skip to content

Commit f8ba58f

Browse files
authored
Fix missing grammar parameter in getValue() for laravel 10. (#591)
* Update LivewireDatatables to support DB::raw with laravel version 10. * Update style * Switch to correct function. * Switch to correct function. * Fix style. * Update x-datatables.x-circle to x-icon * Update x-datatables.x-circle to x-icon
1 parent 59167e8 commit f8ba58f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

resources/views/livewire/datatables/filters/datetime.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/>
77
<div class="absolute inset-y-0 right-0 pr-2 flex items-center">
88
<button x-on:click="$refs.start.value=''" wire:click="doDatetimeFilterStart('{{ $index }}', '')" class="-mb-0.5 pr-1 flex text-gray-400 hover:text-red-600 focus:outline-none" tabindex="-1">
9-
<x-datatables.icons.x-circle class="h-5 w-5 stroke-current" />
9+
<x-icons.x-circle class="h-5 w-5 stroke-current" />
1010
</button>
1111
</div>
1212
</div>
@@ -17,7 +17,7 @@
1717
/>
1818
<div class="absolute inset-y-0 right-0 pr-2 flex items-center">
1919
<button x-on:click="$refs.end.value=''" wire:click="doDatetimeFilterEnd('{{ $index }}', '')" class="-mb-0.5 pr-1 flex text-gray-400 hover:text-red-600 focus:outline-none" tabindex="-1">
20-
<x-datatables.icons.x-circle class="h-5 w-5 stroke-current" />
20+
<x-icons.x-circle class="h-5 w-5 stroke-current" />
2121
</button>
2222
</div>
2323
</div>

src/Http/Livewire/LivewireDatatable.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ public function getSelectStatements($withAlias = false, $export = false)
414414
if ($column->select instanceof Expression) {
415415
$sep_string = config('database.default') === 'pgsql' ? '"' : '`';
416416

417-
return new Expression($column->select->getValue() . ' AS ' . $sep_string . $column->name . $sep_string);
417+
if (version_compare('10.0.0', app()->version()) == -1) {
418+
return new Expression($column->select->getValue(DB::getQueryGrammar()) . ' AS ' . $sep_string . $column->name . $sep_string);
419+
} else {
420+
return new Expression($column->select->getValue() . ' AS ' . $sep_string . $column->name . $sep_string);
421+
}
418422
}
419423

420424
if (is_array($column->select)) {
@@ -440,8 +444,8 @@ protected function resolveColumnName($column, $additional = null)
440444
return $this->query->getModel()->getTable() . '.' . ($column->base ?? Str::before($column->name, ':'));
441445
}
442446

443-
$relations = explode('.', Str::before(($additional ?: $column->name), ':'));
444-
$aggregate = Str::after(($additional ?: $column->name), ':');
447+
$relations = explode('.', Str::before($additional ?: $column->name, ':'));
448+
$aggregate = Str::after($additional ?: $column->name, ':');
445449

446450
if (! method_exists($this->query->getModel(), $relations[0])) {
447451
return $additional ?: $column->name;

0 commit comments

Comments
 (0)