diff --git a/app/Datagrids/Filters/ItemFilter.php b/app/Datagrids/Filters/ItemFilter.php index 9bcab31740..a3ad64cc7e 100644 --- a/app/Datagrids/Filters/ItemFilter.php +++ b/app/Datagrids/Filters/ItemFilter.php @@ -16,6 +16,7 @@ public function build() ->add('type') ->add('price') ->add('size') + ->add('is_equipped') ->add([ 'field' => 'item_id', 'label' => __('crud.fields.parent'), diff --git a/app/Http/Controllers/CrudController.php b/app/Http/Controllers/CrudController.php index 3e7483dd2e..1a77a3fb69 100644 --- a/app/Http/Controllers/CrudController.php +++ b/app/Http/Controllers/CrudController.php @@ -13,7 +13,6 @@ use App\Models\Entity; use App\Models\AttributeTemplate; use App\Models\Bookmark; -use App\Models\Family; use App\Models\MiscModel; use App\Sanitizers\MiscSanitizer; use App\Services\MultiEditingService; diff --git a/app/Http/Controllers/Front/HelperController.php b/app/Http/Controllers/Front/HelperController.php index 3a7c88c79b..706fd2dbaf 100644 --- a/app/Http/Controllers/Front/HelperController.php +++ b/app/Http/Controllers/Front/HelperController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers\Front; -use App\Models\Family; use App\Models\MiscModel; use Exception; use Illuminate\Support\Str; diff --git a/app/Models/Concerns/HasFilters.php b/app/Models/Concerns/HasFilters.php index c59cddb202..09f0f0dfec 100644 --- a/app/Models/Concerns/HasFilters.php +++ b/app/Models/Concerns/HasFilters.php @@ -138,6 +138,8 @@ public function scopeFilter(Builder $query, array $params = []): Builder $this->filterTemplate($query, $value); } elseif ($key == 'has_posts') { $this->filterHasPosts($query, $value); + } elseif ($key == 'is_equipped') { + $this->filterIsEquipped($query, $value); } elseif ($key == 'has_attributes') { $this->filterHasAttributes($query, $value); } elseif ($key == 'has_entity_files') { @@ -350,6 +352,21 @@ protected function filterHasPosts(Builder $query, string $value = null): void } } + /** + * Filter on entities that are equipped + */ + protected function filterIsEquipped(Builder $query, string $value = null): void + { + $query + ->leftJoin('inventories', 'inventories.item_id', 'items.id'); + + if ($value) { + $query->whereNotNull('inventories.id'); + } else { + $query->whereNull('inventories.id'); + } + } + /** * Filter on entities with attributes */ diff --git a/app/Models/Item.php b/app/Models/Item.php index 90b340d028..dbf9732e03 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -296,6 +296,7 @@ public function filterableColumns(): array 'price', 'size', 'item_id', + 'is_equipped', ]; } diff --git a/app/Models/MiscModel.php b/app/Models/MiscModel.php index 934bc5ed1c..22d8c75c44 100644 --- a/app/Models/MiscModel.php +++ b/app/Models/MiscModel.php @@ -7,7 +7,6 @@ use App\Facades\Img; use App\Facades\Mentions; use App\Facades\Module; -use App\Models\Concerns\HasFilters; use App\Models\Concerns\LastSync; use App\Models\Concerns\Orderable; use App\Models\Concerns\Paginatable; diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 5c1e14d3ed..95af42872f 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -12,7 +12,6 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Staudenmeir\LaravelAdjacencyList\Eloquent\HasRecursiveRelationships; diff --git a/app/Services/Campaign/Import/Mappers/EntityMapper.php b/app/Services/Campaign/Import/Mappers/EntityMapper.php index 4188e51f7a..d70041d5a2 100644 --- a/app/Services/Campaign/Import/Mappers/EntityMapper.php +++ b/app/Services/Campaign/Import/Mappers/EntityMapper.php @@ -365,7 +365,7 @@ protected function relations(): self 'relation', 'visibility_id', 'attitude', 'is_pinned', 'colour', 'marketplace_uuid' ]; foreach ($this->data['entity']['relationships'] as $data) { - if (!ImportIdMapper::hasEntity( $data['target_id'])) { + if (!ImportIdMapper::hasEntity($data['target_id'])) { continue; } $targetID = ImportIdMapper::getEntity($data['target_id']); diff --git a/lang/en/items.php b/lang/en/items.php index 7e62bbb69d..edec0ae011 100644 --- a/lang/en/items.php +++ b/lang/en/items.php @@ -5,9 +5,10 @@ 'title' => 'New Item', ], 'fields' => [ - 'character' => 'Creator', - 'price' => 'Price', - 'size' => 'Size', + 'character' => 'Creator', + 'price' => 'Price', + 'size' => 'Size', + 'is_equipped' => 'Equipped' ], 'helpers' => [ 'nested_without' => 'Displaying all items that don\'t have a parent item. Click on a row to see the children items.',