diff --git a/app/Datagrids/Bulks/CreatureBulk.php b/app/Datagrids/Bulks/CreatureBulk.php index 7b83aa6be6..bbaf852f4d 100644 --- a/app/Datagrids/Bulks/CreatureBulk.php +++ b/app/Datagrids/Bulks/CreatureBulk.php @@ -12,11 +12,13 @@ class CreatureBulk extends Bulk 'tags', 'private_choice', 'extinct_choice', + 'dead_choice', 'entity_image', 'entity_header', ]; protected $booleans = [ - 'is_extinct' + 'is_extinct', + 'is_dead', ]; } diff --git a/app/Datagrids/Filters/CreatureFilter.php b/app/Datagrids/Filters/CreatureFilter.php index 45ac6e0ebd..ed657441a1 100644 --- a/app/Datagrids/Filters/CreatureFilter.php +++ b/app/Datagrids/Filters/CreatureFilter.php @@ -24,6 +24,7 @@ public function build() ]) ->location() ->add('is_extinct') + ->add('is_dead') ->isPrivate() ->template() ->hasImage() diff --git a/app/Http/Resources/CreatureResource.php b/app/Http/Resources/CreatureResource.php index 8c4fc0c778..0e1fdf8a01 100644 --- a/app/Http/Resources/CreatureResource.php +++ b/app/Http/Resources/CreatureResource.php @@ -21,7 +21,8 @@ public function toArray($request) return $this->entity([ 'type' => $model->type, 'creature_id' => $model->creature_id, - 'is_extinct' => (bool) $model->is_extinct, + 'is_extinct' => $model->isExtinct(), + 'is_dead' => $model->isDead(), 'locations' => $locationIDs ]); } diff --git a/app/Models/Creature.php b/app/Models/Creature.php index e76cd275f7..aa940adc3e 100644 --- a/app/Models/Creature.php +++ b/app/Models/Creature.php @@ -26,6 +26,7 @@ * * @property ?int $creature_id * @property bool|int $is_extinct + * @property bool|int $is_dead */ class Creature extends MiscModel { @@ -50,6 +51,7 @@ class Creature extends MiscModel 'is_private', 'creature_id', 'is_extinct', + 'is_dead', ]; /** @@ -59,6 +61,7 @@ class Creature extends MiscModel protected array $sortableColumns = [ 'is_extinct', + 'is_dead', ]; protected string $locationPivot = 'creature_location'; @@ -69,6 +72,7 @@ class Creature extends MiscModel 'type', 'parent.name', 'is_extinct', + 'is_dead', ]; /** @@ -89,9 +93,10 @@ class Creature extends MiscModel protected array $exportFields = [ 'base', 'is_extinct', + 'is_dead', ]; - protected array $exploreGridFields = ['is_extinct']; + protected array $exploreGridFields = ['is_extinct', 'is_dead']; protected array $sanitizable = [ 'name', @@ -139,7 +144,7 @@ public function scopePreparedWith(Builder $query): Builder */ public function datagridSelectFields(): array { - return ['creature_id', 'is_extinct']; + return ['creature_id', 'is_extinct', 'is_dead']; } /** @@ -160,6 +165,7 @@ public function filterableColumns(): array 'creature_id', 'location_id', 'is_extinct', + 'is_dead', ]; } @@ -188,6 +194,14 @@ public function isExtinct(): bool return (bool) $this->is_extinct; } + /** + * Determine if the model is dead. + */ + public function isDead(): bool + { + return (bool) $this->is_dead; + } + /** * Detach children when moving this entity from one campaign to another */ diff --git a/database/migrations/2024_08_13_202759_update_creatures_add_is_dead.php b/database/migrations/2024_08_13_202759_update_creatures_add_is_dead.php new file mode 100644 index 0000000000..d21e593096 --- /dev/null +++ b/database/migrations/2024_08_13_202759_update_creatures_add_is_dead.php @@ -0,0 +1,29 @@ +boolean('is_dead')->default(0); + $table->index('is_dead'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('creatures', function (Blueprint $table) { + $table->dropIndex('is_dead'); + $table->dropColumn('is_dead'); + }); + } +}; diff --git a/lang/en/creatures.php b/lang/en/creatures.php index aa4bb52371..8dc5347f75 100644 --- a/lang/en/creatures.php +++ b/lang/en/creatures.php @@ -9,6 +9,7 @@ ], 'hints' => [ 'is_extinct' => 'This creature is extinct.', + 'is_dead' => 'This creature is dead.', ], 'placeholders' => [ 'type' => 'Herbivore, Aquatic, Mythical', diff --git a/resources/api-docs/1.0/creatures.md b/resources/api-docs/1.0/creatures.md index dfd723b04a..8161d57796 100644 --- a/resources/api-docs/1.0/creatures.md +++ b/resources/api-docs/1.0/creatures.md @@ -47,6 +47,7 @@ The list of returned entities can be filtered. The available filters are [availa "creature_id": null, "type": "Bird", "is_extinct": true, + "is_dead": true, "locations": [ 67, 66, @@ -87,6 +88,7 @@ To get the details of a single creature, use the following endpoint. "creature_id": null, "type": "Bird", "is_extinct": true, + "is_dead": true, "locations": [ 67, 66, @@ -118,6 +120,7 @@ To create a creature, use the following endpoint. | `tags` | `array` | Array of tag ids | | `locations` | `array` | Array of location ids | | `is_extinct` | `boolean` | If the creature is extinct | +| `is_dead` | `boolean` | If the creature is dead | | `entity_image_uuid` | `string` | Gallery image UUID for the entity image | | `entity_header_uuid` | `string` | Gallery image UUID for the entity header (limited to premium campaigns) | | `is_private` | `boolean` | If the creature is only visible to `admin` members of the campaign | diff --git a/resources/views/creatures/datagrid.blade.php b/resources/views/creatures/datagrid.blade.php index 4d498f143e..f96186e025 100644 --- a/resources/views/creatures/datagrid.blade.php +++ b/resources/views/creatures/datagrid.blade.php @@ -45,6 +45,17 @@ }, 'class' => 'icon' ], + [ + 'label' => '', + 'field' => 'is_dead', + 'render' => function($model) { + if ($model->isDead()) { + return ''; + } + return ''; + }, + 'class' => 'icon' + ], [ 'type' => 'is_private', ] diff --git a/resources/views/creatures/form/_entry.blade.php b/resources/views/creatures/form/_entry.blade.php index 21375af677..1663461741 100644 --- a/resources/views/creatures/form/_entry.blade.php +++ b/resources/views/creatures/form/_entry.blade.php @@ -14,6 +14,15 @@ + + + + is_dead ?? $model->is_dead ?? false)) checked="checked" @endif /> + + + @include('cruds.fields.tags') @include('cruds.fields.image') diff --git a/resources/views/entities/components/header.blade.php b/resources/views/entities/components/header.blade.php index 44b99fad29..fc5daaf49c 100644 --- a/resources/views/entities/components/header.blade.php +++ b/resources/views/entities/components/header.blade.php @@ -150,6 +150,12 @@ {{ __('creatures.hints.is_extinct') }} @endif + @if ($model instanceof \App\Models\Creature && $model->isDead()) + + + {{ __('creatures.hints.is_dead') }} + + @endif @if (auth()->check() && auth()->user()->isAdmin()) diff --git a/resources/views/entities/pages/print/markdown.blade.php b/resources/views/entities/pages/print/markdown.blade.php index aab79a4d6c..cab91b1ec1 100644 --- a/resources/views/entities/pages/print/markdown.blade.php +++ b/resources/views/entities/pages/print/markdown.blade.php @@ -22,6 +22,9 @@ @if ($model instanceof \App\Models\Creature && $model->isExtinct()) {{ __('creatures.hints.is_extinct') }} @endif +@if ($model instanceof \App\Models\Creature && $model->isDead()) +{{ __('creatures.hints.is_dead') }} +@endif @if ($model instanceof \App\Models\Character && !empty($model->title)) {{ $model->title }}