Allow artworks to have one primary category and extra secondaries.
Keep artwork_category as membership, store a deterministic primary_category_id, and let upload plus studio pick up to five additional same-type categories without changing canonical URLs.
This commit is contained in:
@@ -5,26 +5,27 @@ declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Studio;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Group;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\Group;
|
||||
use App\Services\ArtworkEvolutionService;
|
||||
use App\Services\Artworks\ArtworkPublicationService;
|
||||
use App\Services\GroupMembershipService;
|
||||
use App\Services\GroupService;
|
||||
use App\Services\Studio\CreatorStudioActivityService;
|
||||
use App\Services\Studio\CreatorStudioAnalyticsService;
|
||||
use App\Services\Studio\CreatorStudioAssetService;
|
||||
use App\Services\Studio\CreatorStudioCalendarService;
|
||||
use App\Services\Studio\CreatorStudioChallengeService;
|
||||
use App\Services\Studio\CreatorStudioCommentService;
|
||||
use App\Services\Studio\CreatorStudioContentService;
|
||||
use App\Services\Studio\CreatorStudioFollowersService;
|
||||
use App\Services\Studio\CreatorStudioGrowthService;
|
||||
use App\Services\Studio\CreatorStudioActivityService;
|
||||
use App\Services\Studio\CreatorStudioInboxService;
|
||||
use App\Services\Studio\CreatorStudioOverviewService;
|
||||
use App\Services\Studio\CreatorStudioPreferenceService;
|
||||
use App\Services\Studio\CreatorStudioChallengeService;
|
||||
use App\Services\Studio\CreatorStudioSearchService;
|
||||
use App\Services\Studio\CreatorStudioScheduledService;
|
||||
use App\Services\Studio\CreatorStudioSearchService;
|
||||
use App\Services\Uploads\UploadQueueService;
|
||||
use App\Services\Worlds\WorldSubmissionService;
|
||||
use App\Support\CoverUrl;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -132,7 +133,7 @@ final class StudioController extends Controller
|
||||
|
||||
public function uploadQueue(Request $request): Response
|
||||
{
|
||||
$queue = app(\App\Services\Uploads\UploadQueueService::class)->listPayload(
|
||||
$queue = app(UploadQueueService::class)->listPayload(
|
||||
$request->user(),
|
||||
$request->only(['batch_id', 'status', 'sort'])
|
||||
);
|
||||
@@ -361,7 +362,7 @@ final class StudioController extends Controller
|
||||
'cover_url' => $user->cover_hash && $user->cover_ext ? CoverUrl::forUser($user->cover_hash, $user->cover_ext, time()) : null,
|
||||
'cover_position' => (int) ($user->cover_position ?? 50),
|
||||
'followers' => (int) ($user->statistics?->followers_count ?? 0),
|
||||
'profile_url' => '/@' . strtolower((string) $user->username),
|
||||
'profile_url' => '/@'.strtolower((string) $user->username),
|
||||
'social_links' => $socialLinks,
|
||||
],
|
||||
'moduleSummaries' => $this->content->moduleSummaries($user),
|
||||
@@ -449,13 +450,13 @@ final class StudioController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
$artwork = $user->artworks()
|
||||
->with(['stats', 'categories.contentType', 'tags', 'artworkAiAssist', 'group.members', 'primaryAuthor.profile', 'contributors.user.profile'])
|
||||
->with(['stats', 'categories.contentType', 'primaryCategory.contentType', 'tags', 'artworkAiAssist', 'group.members', 'primaryAuthor.profile', 'contributors.user.profile'])
|
||||
->findOrFail($id);
|
||||
|
||||
$artwork = app(ArtworkPublicationService::class)->publishIfDue($artwork);
|
||||
$artwork->loadMissing(['stats', 'categories.contentType', 'tags', 'artworkAiAssist', 'group.members', 'primaryAuthor.profile', 'contributors.user.profile']);
|
||||
$artwork->loadMissing(['stats', 'categories.contentType', 'primaryCategory.contentType', 'tags', 'artworkAiAssist', 'group.members', 'primaryAuthor.profile', 'contributors.user.profile']);
|
||||
|
||||
$primaryCategory = $artwork->categories->first();
|
||||
$primaryCategory = $artwork->resolvedPrimaryCategory();
|
||||
$availableGroups = app(GroupService::class)->studioOptionsForUser($user);
|
||||
$membershipService = app(GroupMembershipService::class);
|
||||
$contributorOptionsByGroup = [];
|
||||
@@ -470,30 +471,30 @@ final class StudioController extends Controller
|
||||
}
|
||||
|
||||
return Inertia::render('Studio/StudioArtworkEdit', [
|
||||
'artwork' => [
|
||||
'id' => $artwork->id,
|
||||
'title' => $artwork->title,
|
||||
'slug' => $artwork->slug,
|
||||
'description' => $artwork->description,
|
||||
'is_public' => (bool) $artwork->is_public,
|
||||
'visibility' => $artwork->visibility ?: ((bool) $artwork->is_public ? 'public' : 'private'),
|
||||
'is_approved' => (bool) $artwork->is_approved,
|
||||
'publish_mode' => $artwork->artwork_status === 'scheduled' ? 'schedule' : 'now',
|
||||
'publish_at' => $artwork->publish_at?->toIso8601String(),
|
||||
'artwork_status' => $artwork->artwork_status,
|
||||
'artwork' => [
|
||||
'id' => $artwork->id,
|
||||
'title' => $artwork->title,
|
||||
'slug' => $artwork->slug,
|
||||
'description' => $artwork->description,
|
||||
'is_public' => (bool) $artwork->is_public,
|
||||
'visibility' => $artwork->visibility ?: ((bool) $artwork->is_public ? 'public' : 'private'),
|
||||
'is_approved' => (bool) $artwork->is_approved,
|
||||
'publish_mode' => $artwork->artwork_status === 'scheduled' ? 'schedule' : 'now',
|
||||
'publish_at' => $artwork->publish_at?->toIso8601String(),
|
||||
'artwork_status' => $artwork->artwork_status,
|
||||
'artwork_timezone' => $artwork->artwork_timezone,
|
||||
'thumb_url' => $artwork->thumbUrl('md'),
|
||||
'thumb_url_lg' => $artwork->thumbUrl('lg'),
|
||||
'download_url' => route('art.download', ['id' => $artwork->id]),
|
||||
'file_name' => $artwork->file_name,
|
||||
'file_ext' => $artwork->file_ext,
|
||||
'file_size' => $artwork->file_size,
|
||||
'width' => $artwork->width,
|
||||
'height' => $artwork->height,
|
||||
'mime_type' => $artwork->mime_type,
|
||||
'thumb_url' => $artwork->thumbUrl('md'),
|
||||
'thumb_url_lg' => $artwork->thumbUrl('lg'),
|
||||
'download_url' => route('art.download', ['id' => $artwork->id]),
|
||||
'file_name' => $artwork->file_name,
|
||||
'file_ext' => $artwork->file_ext,
|
||||
'file_size' => $artwork->file_size,
|
||||
'width' => $artwork->width,
|
||||
'height' => $artwork->height,
|
||||
'mime_type' => $artwork->mime_type,
|
||||
'has_archive_file' => $this->artworkHasArchiveFile((int) $artwork->id),
|
||||
'screenshots' => $this->screenshotAssetsForArtwork((int) $artwork->id),
|
||||
'group_slug' => $artwork->group?->slug,
|
||||
'screenshots' => $this->screenshotAssetsForArtwork((int) $artwork->id),
|
||||
'group_slug' => $artwork->group?->slug,
|
||||
'primary_author_user_id' => (int) ($artwork->primary_author_user_id ?: $artwork->user_id),
|
||||
'contributor_user_ids' => $artwork->contributors->pluck('user_id')->map(fn ($id): int => (int) $id)->values()->all(),
|
||||
'contributor_credits' => $artwork->contributors->map(fn ($contributor): array => [
|
||||
@@ -502,19 +503,27 @@ final class StudioController extends Controller
|
||||
'is_primary' => (bool) $contributor->is_primary,
|
||||
])->values()->all(),
|
||||
'content_type_id' => $primaryCategory?->contentType?->id,
|
||||
'category_id' => $primaryCategory?->id,
|
||||
'category_id' => $primaryCategory?->id,
|
||||
'primary_category_id' => $primaryCategory?->id,
|
||||
'parent_category_id' => $primaryCategory?->parent_id ? $primaryCategory->parent_id : $primaryCategory?->id,
|
||||
'sub_category_id' => $primaryCategory?->parent_id ? $primaryCategory->id : null,
|
||||
'categories' => $artwork->categories->map(fn ($c) => ['id' => $c->id, 'name' => $c->name, 'slug' => $c->slug])->values()->all(),
|
||||
'tags' => $artwork->tags->map(fn ($t) => ['id' => $t->id, 'name' => $t->name, 'slug' => $t->slug])->values()->all(),
|
||||
'ai_status' => $artwork->ai_status,
|
||||
'title_source' => $artwork->title_source ?: 'manual',
|
||||
'sub_category_id' => $primaryCategory?->parent_id ? $primaryCategory->id : null,
|
||||
'secondary_category_ids' => $artwork->categories
|
||||
->reject(fn ($category): bool => (int) $category->id === (int) ($primaryCategory?->id ?? 0))
|
||||
->pluck('id')
|
||||
->map(fn ($id): int => (int) $id)
|
||||
->values()
|
||||
->all(),
|
||||
'max_secondary_categories' => (int) config('categories.max_secondary_categories', 5),
|
||||
'categories' => $artwork->categories->map(fn ($c) => ['id' => $c->id, 'name' => $c->name, 'slug' => $c->slug, 'is_primary' => (int) $c->id === (int) ($primaryCategory?->id ?? 0)])->values()->all(),
|
||||
'tags' => $artwork->tags->map(fn ($t) => ['id' => $t->id, 'name' => $t->name, 'slug' => $t->slug])->values()->all(),
|
||||
'ai_status' => $artwork->ai_status,
|
||||
'title_source' => $artwork->title_source ?: 'manual',
|
||||
'description_source' => $artwork->description_source ?: 'manual',
|
||||
'tags_source' => $artwork->tags_source ?: 'manual',
|
||||
'tags_source' => $artwork->tags_source ?: 'manual',
|
||||
'category_source' => $artwork->category_source ?: 'manual',
|
||||
'evolution_relation' => app(ArtworkEvolutionService::class)->editorRelation($artwork, $user),
|
||||
// Versioning
|
||||
'version_count' => (int) ($artwork->version_count ?? 1),
|
||||
'version_count' => (int) ($artwork->version_count ?? 1),
|
||||
'requires_reapproval' => (bool) $artwork->requires_reapproval,
|
||||
],
|
||||
'worldSubmissionOptions' => app(WorldSubmissionService::class)->artworkSubmissionOptions($artwork, $user),
|
||||
@@ -538,19 +547,19 @@ final class StudioController extends Controller
|
||||
|
||||
return Inertia::render('Studio/StudioArtworkAnalytics', [
|
||||
'artwork' => [
|
||||
'id' => $artwork->id,
|
||||
'title' => $artwork->title,
|
||||
'slug' => $artwork->slug,
|
||||
'thumb_url' => $artwork->thumbUrl('md'),
|
||||
'id' => $artwork->id,
|
||||
'title' => $artwork->title,
|
||||
'slug' => $artwork->slug,
|
||||
'thumb_url' => $artwork->thumbUrl('md'),
|
||||
],
|
||||
'analytics' => [
|
||||
'views' => (int) ($stats?->views ?? 0),
|
||||
'favourites' => (int) ($stats?->favorites ?? 0),
|
||||
'shares' => (int) ($stats?->shares_count ?? 0),
|
||||
'comments' => (int) ($stats?->comments_count ?? 0),
|
||||
'downloads' => (int) ($stats?->downloads ?? 0),
|
||||
'ranking_score' => (float) ($stats?->ranking_score ?? 0),
|
||||
'heat_score' => (float) ($stats?->heat_score ?? 0),
|
||||
'views' => (int) ($stats?->views ?? 0),
|
||||
'favourites' => (int) ($stats?->favorites ?? 0),
|
||||
'shares' => (int) ($stats?->shares_count ?? 0),
|
||||
'comments' => (int) ($stats?->comments_count ?? 0),
|
||||
'downloads' => (int) ($stats?->downloads ?? 0),
|
||||
'ranking_score' => (float) ($stats?->ranking_score ?? 0),
|
||||
'heat_score' => (float) ($stats?->heat_score ?? 0),
|
||||
'engagement_velocity' => (float) ($stats?->engagement_velocity ?? 0),
|
||||
],
|
||||
]);
|
||||
@@ -569,16 +578,16 @@ final class StudioController extends Controller
|
||||
$data = $this->analytics->overview($user, $rangeDays);
|
||||
|
||||
return Inertia::render('Studio/StudioAnalytics', [
|
||||
'totals' => $data['totals'],
|
||||
'topContent' => $data['top_content'],
|
||||
'moduleBreakdown' => $data['module_breakdown'],
|
||||
'viewsTrend' => $data['views_trend'],
|
||||
'engagementTrend' => $data['engagement_trend'],
|
||||
'totals' => $data['totals'],
|
||||
'topContent' => $data['top_content'],
|
||||
'moduleBreakdown' => $data['module_breakdown'],
|
||||
'viewsTrend' => $data['views_trend'],
|
||||
'engagementTrend' => $data['engagement_trend'],
|
||||
'publishingTimeline' => $data['publishing_timeline'],
|
||||
'comparison' => $data['comparison'],
|
||||
'insightBlocks' => $data['insight_blocks'],
|
||||
'rangeDays' => $data['range_days'],
|
||||
'recentComments' => $this->overview->recentComments($user, 8),
|
||||
'comparison' => $data['comparison'],
|
||||
'insightBlocks' => $data['insight_blocks'],
|
||||
'rangeDays' => $data['range_days'],
|
||||
'recentComments' => $this->overview->recentComments($user, 8),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -586,16 +595,16 @@ final class StudioController extends Controller
|
||||
{
|
||||
return ContentType::with(['rootCategories.children'])->ordered()->get()->map(function ($ct) {
|
||||
return [
|
||||
'id' => $ct->id,
|
||||
'id' => $ct->id,
|
||||
'name' => $ct->name,
|
||||
'slug' => $ct->slug,
|
||||
'categories' => $ct->rootCategories->map(function ($c) {
|
||||
return [
|
||||
'id' => $c->id,
|
||||
'name' => $c->name,
|
||||
'slug' => $c->slug,
|
||||
'id' => $c->id,
|
||||
'name' => $c->name,
|
||||
'slug' => $c->slug,
|
||||
'children' => $c->children->map(fn ($ch) => [
|
||||
'id' => $ch->id,
|
||||
'id' => $ch->id,
|
||||
'name' => $ch->name,
|
||||
'slug' => $ch->slug,
|
||||
])->values()->all(),
|
||||
@@ -642,11 +651,11 @@ final class StudioController extends Controller
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = $base . '/' . $path;
|
||||
$url = $base.'/'.$path;
|
||||
|
||||
return [
|
||||
'id' => (string) ($row->variant ?? ('shot' . ($index + 1))),
|
||||
'label' => 'Screenshot ' . ($index + 1),
|
||||
'id' => (string) ($row->variant ?? ('shot'.($index + 1))),
|
||||
'label' => 'Screenshot '.($index + 1),
|
||||
'url' => $url,
|
||||
'thumb_url' => $url,
|
||||
'mime_type' => (string) ($row->mime ?? 'image/jpeg'),
|
||||
|
||||
Reference in New Issue
Block a user