Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Filter bugs #790

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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