Skip to content

Commit

Permalink
Fix missing grammar parameter in getValue() for laravel 10. (#591)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Nowocyn authored Oct 23, 2023
1 parent 59167e8 commit f8ba58f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/>
<div class="absolute inset-y-0 right-0 pr-2 flex items-center">
<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">
<x-datatables.icons.x-circle class="h-5 w-5 stroke-current" />
<x-icons.x-circle class="h-5 w-5 stroke-current" />
</button>
</div>
</div>
Expand All @@ -17,7 +17,7 @@
/>
<div class="absolute inset-y-0 right-0 pr-2 flex items-center">
<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">
<x-datatables.icons.x-circle class="h-5 w-5 stroke-current" />
<x-icons.x-circle class="h-5 w-5 stroke-current" />
</button>
</div>
</div>
Expand Down
10 changes: 7 additions & 3 deletions src/Http/Livewire/LivewireDatatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ public function getSelectStatements($withAlias = false, $export = false)
if ($column->select instanceof Expression) {
$sep_string = config('database.default') === 'pgsql' ? '"' : '`';

return new Expression($column->select->getValue() . ' AS ' . $sep_string . $column->name . $sep_string);
if (version_compare('10.0.0', app()->version()) == -1) {
return new Expression($column->select->getValue(DB::getQueryGrammar()) . ' AS ' . $sep_string . $column->name . $sep_string);
} else {
return new Expression($column->select->getValue() . ' AS ' . $sep_string . $column->name . $sep_string);
}
}

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

$relations = explode('.', Str::before(($additional ?: $column->name), ':'));
$aggregate = Str::after(($additional ?: $column->name), ':');
$relations = explode('.', Str::before($additional ?: $column->name, ':'));
$aggregate = Str::after($additional ?: $column->name, ':');

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

0 comments on commit f8ba58f

Please sign in to comment.