diff --git a/app/Jobs/CalendarsClearElapsed.php b/app/Jobs/CalendarsClearElapsed.php index 458611e8a0..a1819e3607 100644 --- a/app/Jobs/CalendarsClearElapsed.php +++ b/app/Jobs/CalendarsClearElapsed.php @@ -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; @@ -14,7 +13,10 @@ class CalendarsClearElapsed implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public int $id; /** diff --git a/app/Models/Concerns/HasFilters.php b/app/Models/Concerns/HasFilters.php index 1d2f7f2d21..40b2eebb36 100644 --- a/app/Models/Concerns/HasFilters.php +++ b/app/Models/Concerns/HasFilters.php @@ -71,7 +71,6 @@ protected function defaultFilterableColumns(): array ]; } - /** */ public function scopeFilter(Builder $query, array $params = []): Builder @@ -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; } @@ -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); } } @@ -398,6 +402,7 @@ protected function filterIsEquipped(Builder $query, string $value = null): void } else { $query->whereNull('inventories.id'); } + $query->distinct('items.id'); } /** diff --git a/resources/views/cruds/datagrids/filters/_connection.blade.php b/resources/views/cruds/datagrids/filters/_connection.blade.php index 331adaa738..b89cd3b0d1 100644 --- a/resources/views/cruds/datagrids/filters/_connection.blade.php +++ b/resources/views/cruds/datagrids/filters/_connection.blade.php @@ -14,6 +14,7 @@ :campaign="$campaign" :route="route('search.entities-with-relations', [$campaign])" :selected="$model" + allow-clear="true" >