Skip to content

Commit

Permalink
Merge pull request #790 from owlchester/filters-bug-connections-equipped
Browse files Browse the repository at this point in the history
Fixed Filter bugs
  • Loading branch information
ilestis authored Dec 14, 2023
2 parents 9f70da9 + c62d34b commit 2d474e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/Jobs/CalendarsClearElapsed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Models\Calendar;
use App\Models\EntityEvent;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
Expand All @@ -14,7 +13,10 @@

class CalendarsClearElapsed implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;

public int $id;
/**
Expand Down
11 changes: 8 additions & 3 deletions app/Models/Concerns/HasFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ protected function defaultFilterableColumns(): array
];
}


/**
*/
public function scopeFilter(Builder $query, array $params = []): Builder
Expand Down Expand Up @@ -263,7 +262,7 @@ protected function filterAttributes(Builder $query, string $key): void
*/
protected function filterConnections(Builder $query, string $key): void
{
if ($key == 'connection_name' && Arr::get($this->filterParams, 'connection_target')) {
if ($key == 'connection_target' && Arr::get($this->filterParams, 'connection_name')) {
return;
}

Expand All @@ -281,8 +280,13 @@ protected function filterConnections(Builder $query, string $key): void

$connectionName = Arr::get($this->filterParams, 'connection_name');
if ($connectionName !== '' && $connectionName !== null) {
$connectionName = $this->filterValue;
if ($this->filterOperator != '=') {
$connectionName = '%' . $this->filterValue . '%';
}

$query
->where('rel.relation', 'like', '%' . $connectionName . '%');
->where('rel.relation', $this->filterOperator, $connectionName);
}
}

Expand Down Expand Up @@ -398,6 +402,7 @@ protected function filterIsEquipped(Builder $query, string $value = null): void
} else {
$query->whereNull('inventories.id');
}
$query->distinct('items.id');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:campaign="$campaign"
:route="route('search.entities-with-relations', [$campaign])"
:selected="$model"
allow-clear="true"
>
</x-forms.foreign>

Expand Down

0 comments on commit 2d474e8

Please sign in to comment.