From 34e9c3d10b1052d89063e4736a6bfa54749228f3 Mon Sep 17 00:00:00 2001 From: Spitfire Date: Thu, 5 Sep 2024 10:10:45 -0600 Subject: [PATCH 1/2] Users can now Tag Tags. --- app/Datagrids/Bulks/TagBulk.php | 1 + app/Http/Controllers/Search/LiveController.php | 6 +++--- resources/api-docs/1.0/tags.md | 1 + resources/views/components/forms/tags.blade.php | 2 +- resources/views/entities/components/header.blade.php | 2 -- resources/views/entities/creator/form.blade.php | 2 +- resources/views/tags/entities/_form.blade.php | 2 +- resources/views/tags/form/_entry.blade.php | 2 ++ 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Datagrids/Bulks/TagBulk.php b/app/Datagrids/Bulks/TagBulk.php index 7bafb7391a..9d169fced1 100644 --- a/app/Datagrids/Bulks/TagBulk.php +++ b/app/Datagrids/Bulks/TagBulk.php @@ -12,6 +12,7 @@ class TagBulk extends Bulk 'private_choice', 'auto_applied_choice', 'hide_choice', + 'tags', 'entity_image', 'entity_header', ]; diff --git a/app/Http/Controllers/Search/LiveController.php b/app/Http/Controllers/Search/LiveController.php index e027b26add..08ebb3958d 100644 --- a/app/Http/Controllers/Search/LiveController.php +++ b/app/Http/Controllers/Search/LiveController.php @@ -112,17 +112,17 @@ public function tagChildren(Request $request, Campaign $campaign) $term = trim($request->get('q', '')); $exclude = []; - if ($request->has('exclude')) { + if ($request->has('exclude-entity')) { /** @var Tag $tag */ - $tag = Tag::findOrFail($request->get('exclude')); + $tag = Tag::findOrFail($request->get('exclude-entity')); $exclude = $tag->entities->pluck('id')->toArray(); + $exclude[] = $tag->entity->id; } return response()->json( $this->search ->term($term) ->campaign($campaign) - ->exclude([config('entities.ids.tag')]) ->excludeIds($exclude) ->find() ); diff --git a/resources/api-docs/1.0/tags.md b/resources/api-docs/1.0/tags.md index 4bb5579d59..c23d19ff70 100644 --- a/resources/api-docs/1.0/tags.md +++ b/resources/api-docs/1.0/tags.md @@ -119,6 +119,7 @@ To create a tag, use the following endpoint. | `type` | `string` | The tag's type | | `colour` | `string` | The tag's colour | | `tag_id` | `integer` | The parent tag | +| `tags` | `array` | Array of tag ids | | `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 tag is only visible to `admin` members of the campaign | diff --git a/resources/views/components/forms/tags.blade.php b/resources/views/components/forms/tags.blade.php index 3219fdaee9..7e6b50960a 100644 --- a/resources/views/components/forms/tags.blade.php +++ b/resources/views/components/forms/tags.blade.php @@ -10,7 +10,7 @@ is_hidden ?? false)) checked="checked" @endif /> + + @include('cruds.fields.tags') @include('cruds.fields.image') From e4bb3d016abab7769bea18e4717ad4d01da59699 Mon Sep 17 00:00:00 2001 From: spitfire305 Date: Thu, 5 Sep 2024 16:12:33 +0000 Subject: [PATCH 2/2] Fix styling --- app/Console/Commands/Migrations/MigrateTutorials.php | 2 +- .../Controllers/Entity/Attributes/LiveApiController.php | 2 -- app/Http/Middleware/ApiLogMiddleware.php | 1 - app/Http/Middleware/OTPMiddleware.php | 1 - app/Http/Resources/Attributes/LiveAttributeResource.php | 2 -- app/Http/Resources/GalleryFileFull.php | 4 ++-- app/Renderers/DatagridRenderer2.php | 2 +- app/Services/BulkService.php | 2 +- app/Services/EntityMappingService.php | 1 - app/View/Components/Ad.php | 8 ++++---- app/View/Components/Cta.php | 2 +- app/View/Components/Dialog.php | 2 +- database/factories/CharacterFactory.php | 1 - .../2017_10_30_010000_create_real_visibilities_table.php | 2 +- 14 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/Migrations/MigrateTutorials.php b/app/Console/Commands/Migrations/MigrateTutorials.php index 692810cd3a..39b9ff99a2 100644 --- a/app/Console/Commands/Migrations/MigrateTutorials.php +++ b/app/Console/Commands/Migrations/MigrateTutorials.php @@ -45,7 +45,7 @@ public function handle() $tutorial->code = mb_substr($key, 9); $tutorial->save(); unset($settings[$key]); - } elseif(str_starts_with($key, 'releases_')) { + } elseif (str_starts_with($key, 'releases_')) { $tutorial = new Tutorial(); $tutorial->user_id = $user->id; $tutorial->code = $key . '_' . $setting; diff --git a/app/Http/Controllers/Entity/Attributes/LiveApiController.php b/app/Http/Controllers/Entity/Attributes/LiveApiController.php index 7193a14541..36967e68cb 100644 --- a/app/Http/Controllers/Entity/Attributes/LiveApiController.php +++ b/app/Http/Controllers/Entity/Attributes/LiveApiController.php @@ -5,12 +5,10 @@ use App\Http\Controllers\Controller; use App\Http\Requests\StoreAttribute; use App\Http\Requests\UpdateAttribute; -use App\Http\Requests\UpdateEntityAttribute; use App\Http\Resources\Attributes\LiveAttributeResource; use App\Models\Attribute; use App\Models\Campaign; use App\Models\Entity; -use App\Services\Attributes\ApiService; use App\Traits\GuestAuthTrait; class LiveApiController extends Controller diff --git a/app/Http/Middleware/ApiLogMiddleware.php b/app/Http/Middleware/ApiLogMiddleware.php index db73ecc72f..e4696c6f48 100644 --- a/app/Http/Middleware/ApiLogMiddleware.php +++ b/app/Http/Middleware/ApiLogMiddleware.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use App\Facades\ApiLog; - use Closure; class ApiLogMiddleware diff --git a/app/Http/Middleware/OTPMiddleware.php b/app/Http/Middleware/OTPMiddleware.php index 1d737bb206..07a94b4783 100644 --- a/app/Http/Middleware/OTPMiddleware.php +++ b/app/Http/Middleware/OTPMiddleware.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use App\Models\Google2FAAuthentication; - use Closure; use App\Facades\Identity; diff --git a/app/Http/Resources/Attributes/LiveAttributeResource.php b/app/Http/Resources/Attributes/LiveAttributeResource.php index 7efbfbcf5d..796876e611 100644 --- a/app/Http/Resources/Attributes/LiveAttributeResource.php +++ b/app/Http/Resources/Attributes/LiveAttributeResource.php @@ -3,8 +3,6 @@ namespace App\Http\Resources\Attributes; use App\Models\Attribute; -use App\Traits\CampaignAware; -use App\Traits\EntityAware; use Illuminate\Http\Resources\Json\JsonResource; class LiveAttributeResource extends JsonResource diff --git a/app/Http/Resources/GalleryFileFull.php b/app/Http/Resources/GalleryFileFull.php index 155d701ab4..2303cccdbc 100644 --- a/app/Http/Resources/GalleryFileFull.php +++ b/app/Http/Resources/GalleryFileFull.php @@ -19,7 +19,7 @@ public function toArray(Request $request): array $file = $this->resource; $mentions = []; - foreach($file->inEntities() as $entity) { + foreach ($file->inEntities() as $entity) { $mentions[] = [ 'url' => $entity->url(), 'name' => $entity->name, @@ -27,7 +27,7 @@ public function toArray(Request $request): array ]; } foreach ($file->mentions as $mention) { - if($mention->isPost()) { + if ($mention->isPost()) { $mentions[] = [ 'url' => $mention->entity->url() . '?#post-' . $mention->post_id, 'name' => $mention->post->name, diff --git a/app/Renderers/DatagridRenderer2.php b/app/Renderers/DatagridRenderer2.php index 8946f4ef5a..69de965035 100644 --- a/app/Renderers/DatagridRenderer2.php +++ b/app/Renderers/DatagridRenderer2.php @@ -273,7 +273,7 @@ public function isHighlighted(mixed $row): bool public function rowAttributes(mixed $row): string { $attributes = []; - foreach($row->rowAttributes() as $attr => $val) { + foreach ($row->rowAttributes() as $attr => $val) { if ($val instanceof UnitEnum) { // @phpstan-ignore-next-line $val = $val->value; diff --git a/app/Services/BulkService.php b/app/Services/BulkService.php index f46f7ffde5..40c08628e7 100644 --- a/app/Services/BulkService.php +++ b/app/Services/BulkService.php @@ -310,7 +310,7 @@ public function editing(array $fields, Bulk $bulk): int } $entityFields = $filledFields; - if(isset($entityFields[$parent]) && intval($entityFields[$parent]) == $entity->id) { + if (isset($entityFields[$parent]) && intval($entityFields[$parent]) == $entity->id) { unset($entityFields[$parent]); } diff --git a/app/Services/EntityMappingService.php b/app/Services/EntityMappingService.php index a407a0ed74..d01e246b6b 100644 --- a/app/Services/EntityMappingService.php +++ b/app/Services/EntityMappingService.php @@ -10,7 +10,6 @@ use App\Models\Post; use App\Models\QuestElement; use App\Models\TimelineElement; - use App\Traits\MentionTrait; use Exception; use Illuminate\Database\Eloquent\Model; diff --git a/app/View/Components/Ad.php b/app/View/Components/Ad.php index e7c11e0611..10adbcc65c 100644 --- a/app/View/Components/Ad.php +++ b/app/View/Components/Ad.php @@ -57,11 +57,11 @@ protected function hasAd(): bool return false; } // Parameter to force ads to be displayed - if (request()->has('_showads')) { - return true; - } + return (bool) (request()->has('_showads')) + + // Temp workaround for venatus to fix their ads - return false; + ; if (isset($this->user)) { // Subscribed users don't have ads if ($this->user->isSubscriber()) { diff --git a/app/View/Components/Cta.php b/app/View/Components/Cta.php index c0a8926dab..7b8cc6ba8e 100644 --- a/app/View/Components/Cta.php +++ b/app/View/Components/Cta.php @@ -21,7 +21,7 @@ public function __construct( public bool $superboost = false, public bool $premium = false, public bool $minimal = false, - public bool $max = false, + public bool $max = false, ) { } diff --git a/app/View/Components/Dialog.php b/app/View/Components/Dialog.php index 5b0e70be67..a39a23d21d 100644 --- a/app/View/Components/Dialog.php +++ b/app/View/Components/Dialog.php @@ -18,7 +18,7 @@ public function __construct( public array $form = [], public bool $full = false, public bool $loading = false, - public bool $dismissible = true, + public bool $dismissible = true, ) { if (empty($this->id)) { $this->id = uniqid(); diff --git a/database/factories/CharacterFactory.php b/database/factories/CharacterFactory.php index fdf9878598..08d6acffd6 100644 --- a/database/factories/CharacterFactory.php +++ b/database/factories/CharacterFactory.php @@ -3,7 +3,6 @@ namespace Database\Factories; //use Faker\Generator as Faker; -use Illuminate\Support\Str; use Illuminate\Database\Eloquent\Factories\Factory; use App\Models\Character; diff --git a/database/migrations/2017_10_30_010000_create_real_visibilities_table.php b/database/migrations/2017_10_30_010000_create_real_visibilities_table.php index 420d14cbcc..8ac1aea345 100644 --- a/database/migrations/2017_10_30_010000_create_real_visibilities_table.php +++ b/database/migrations/2017_10_30_010000_create_real_visibilities_table.php @@ -13,7 +13,7 @@ class CreateRealVisibilitiesTable extends Migration */ public function up() { - if(Schema::hasTable('visibilities')) { + if (Schema::hasTable('visibilities')) { return; } Schema::create('visibilities', function (Blueprint $table) {