Save workspace changes

This commit is contained in:
2026-04-18 17:02:56 +02:00
parent f02ea9a711
commit 87d60af5a9
4220 changed files with 1388603 additions and 1554 deletions

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class AccountHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.account');
$seo = app(SeoFactory::class)
->collectionPage(
'Account Settings Help — Skinbase',
'Learn how account settings, profile settings, email changes, password care, and creator preferences work on Skinbase Nova.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/AccountHelpPage', [
'title' => 'Account Settings Help',
'description' => 'Use this guide when account access already works and you need practical help with settings, identity details, email and password care, or ongoing account maintenance.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'help_auth' => route('help.auth'),
'help_profile' => route('help.profile'),
'studio_help' => route('help.studio'),
'upload_help' => route('help.upload'),
'help_troubleshooting' => route('help.troubleshooting'),
'profile_settings' => route('dashboard.profile'),
'open_studio' => route('studio.index'),
'login' => route('login'),
'register' => route('register'),
'password_request' => route('password.request'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use App\Models\StaffApplication;
class ApplicationController extends Controller
{
public function show()
{
return view('web.apply');
}
public function submit(Request $request)
{
$data = $request->validate([
'topic' => 'required|string|in:apply,bug,contact,other',
'name' => 'required|string|max:100',
'email' => 'required|email|max:150',
'role' => 'nullable|string|max:100',
'portfolio' => 'nullable|url|max:255',
'affected_url' => 'nullable|url|max:255',
'steps' => 'nullable|string|max:2000',
'message' => 'nullable|string|max:2000',
]);
$payload = [
'id' => (string) Str::uuid(),
'submitted_at' => now()->toISOString(),
'ip' => $request->ip(),
'user_agent' => $request->userAgent(),
'data' => $data,
];
// Honeypot: silently drop submissions that fill the hidden field
if ($request->filled('website')) {
return redirect()->route('contact.show')->with('success', 'Your submission was received.');
}
try {
Storage::append('staff_applications.jsonl', json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
} catch (\Throwable $e) {
// best-effort store; don't fail the user if write fails
}
// store in DB as well
try {
StaffApplication::create([
'id' => $payload['id'],
'topic' => $data['topic'] ?? 'apply',
'name' => $data['name'] ?? null,
'email' => $data['email'] ?? null,
'role' => $data['role'] ?? null,
'portfolio' => $data['portfolio'] ?? null,
'message' => $data['message'] ?? null,
'payload' => $payload,
'ip' => $payload['ip'],
'user_agent' => $payload['user_agent'],
]);
} catch (\Throwable $e) {
// ignore DB errors
}
$to = config('mail.from.address');
if ($to) {
try {
// prefer the DB model when available
$appModel = isset($appModel) ? $appModel : StaffApplication::find($payload['id']) ?? null;
if (! $appModel) {
// construct a lightweight model-like object for the mailable
$appModel = new StaffApplication($payload['data'] ?? []);
$appModel->id = $payload['id'];
$appModel->payload = $payload;
$appModel->ip = $payload['ip'];
$appModel->user_agent = $payload['user_agent'];
$appModel->created_at = now();
}
Mail::to($to)->queue(new \App\Mail\StaffApplicationReceived($appModel));
} catch (\Throwable $e) {
// ignore mail errors but don't fail user
}
}
return redirect()->route('contact.show')->with('success', 'Your submission was received. Thank you — we will review it soon.');
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\LegacyService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class ArtController extends Controller
{
protected LegacyService $legacy;
public function __construct(LegacyService $legacy)
{
$this->legacy = $legacy;
}
public function show(Request $request, $id, $slug = null)
{
// Keep this controller for legacy comment posting and fallback only.
// Canonical artwork page rendering is handled by ArtworkPageController.
try {
$art = \App\Models\Artwork::find((int) $id);
if ($art && $request->isMethod('get')) {
$canonicalSlug = Str::slug((string) ($art->slug ?: $art->title));
if ($canonicalSlug === '') {
$canonicalSlug = (string) $art->id;
}
return redirect()->route('art.show', [
'id' => (int) $art->id,
'slug' => $canonicalSlug,
], 301);
}
} catch (\Throwable $e) {
// keep legacy fallback below
}
if ($request->isMethod('post') && $request->input('action') === 'store_comment') {
if (auth()->check()) {
try {
DB::table('artwork_comments')->insert([
'artwork_id' => (int)$id,
'owner_user_id' => (int)($request->user()->id ?? 0),
'user_id' => (int)$request->user()->id,
'date' => now()->toDateString(),
'time' => now()->toTimeString(),
'description' => (string)$request->input('comment_text'),
]);
} catch (\Throwable $e) {
// ignore DB errors for now
}
}
return redirect()->back();
}
$data = $this->legacy->getArtwork((int) $id);
if (! $data || empty($data['artwork'])) {
return view('shared.placeholder', ['title' => 'Artwork Not Found']);
}
try {
$comments = DB::table('artwork_comments as t1')
->rightJoin('users as t2', 't1.user_id', '=', 't2.user_id')
->select('t1.description', 't1.date', 't1.time', 't2.uname', 't2.signature', 't2.icon', 't2.user_id')
->where('t1.artwork_id', (int)$id)
->where('t1.user_id', '>', 0)
->orderBy('t1.comment_id')
->get();
} catch (\Throwable $e) {
$comments = collect();
}
$data['comments'] = $comments;
return view('web.art', $data);
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\ArtworkService;
use App\Models\Category;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class ArtworkController extends Controller
{
protected ArtworkService $service;
public function __construct(ArtworkService $service)
{
$this->service = $service;
}
/**
* Browse artworks for a category (Blade view).
*/
public function category(Request $request, Category $category): View
{
$perPage = (int) $request->get('per_page', 24);
$artworks = $this->service->getCategoryArtworks($category, $perPage);
return view('artworks.index', [
'artworks' => $artworks,
'category' => $category,
]);
}
/**
* Show single artwork page by slug (Blade view).
*/
public function show(string $slug): View
{
try {
$artwork = $this->service->getPublicArtworkBySlug($slug);
} catch (ModelNotFoundException $e) {
abort(404);
}
// Prepare simple SEO meta data for Blade; keep controller thin.
$meta = [
'title' => $artwork->title,
'description' => str(config($artwork->description ?? ''))->limit(160),
'canonical' => $artwork->canonical_url ?? null,
];
return view('artworks.show', [
'artwork' => $artwork,
'meta' => $meta,
]);
}
}

View File

@@ -0,0 +1,271 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Http\Resources\ArtworkResource;
use App\Models\Artwork;
use App\Models\ArtworkComment;
use App\Services\ContentSanitizer;
use App\Services\ThumbnailPresenter;
use App\Services\ErrorSuggestionService;
use App\Services\GroupService;
use App\Services\Maturity\ArtworkMaturityService;
use App\Support\Seo\SeoFactory;
use App\Support\AvatarUrl;
use Illuminate\Support\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Str;
use Illuminate\View\View;
final class ArtworkPageController extends Controller
{
public function __construct(
private readonly GroupService $groups,
private readonly ArtworkMaturityService $maturity,
) {}
public function show(Request $request, int $id, ?string $slug = null): View|RedirectResponse|Response
{
// ── Step 1: check existence including soft-deleted ─────────────────
$raw = Artwork::withTrashed()->where('id', $id)->first();
if (! $raw) {
// Artwork never existed → contextual 404
$suggestions = app(ErrorSuggestionService::class);
return response(view('errors.contextual.artwork-not-found', [
'trendingArtworks' => $this->safeSuggestions(fn () => $suggestions->trendingArtworks()),
]), 404);
}
if ($raw->trashed()) {
// Artwork permanently deleted → 410 Gone
return response(view('errors.410'), 410);
}
if (! $raw->is_public || ! $raw->is_approved) {
// Artwork exists but is private/unapproved → 403 Forbidden.
// Show other public artworks by the same creator as recovery suggestions.
$suggestions = app(ErrorSuggestionService::class);
$creatorArtworks = collect();
$creatorUsername = null;
if ($raw->user_id) {
$raw->loadMissing('user');
$creatorUsername = $raw->user?->username;
$creatorArtworks = $this->safeSuggestions(function () use ($raw) {
return Artwork::query()
->with('user')
->where('user_id', $raw->user_id)
->where('id', '!=', $raw->id)
->public()
->published()
->limit(6)
->get()
->map(function (Artwork $a) {
$slug = \Illuminate\Support\Str::slug((string) ($a->slug ?: $a->title)) ?: (string) $a->id;
$md = \App\Services\ThumbnailPresenter::present($a, 'md');
return [
'id' => $a->id,
'title' => html_entity_decode((string) $a->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'author' => html_entity_decode((string) ($a->user?->name ?: $a->user?->username ?: 'Artist'), ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'url' => route('art.show', ['id' => $a->id, 'slug' => $slug]),
'thumb' => $md['url'] ?? null,
];
});
});
}
return response(view('errors.contextual.artwork-not-found', [
'message' => 'This artwork is not publicly available.',
'isForbidden' => true,
'creatorArtworks' => $creatorArtworks,
'creatorUsername' => $creatorUsername,
'trendingArtworks' => $this->safeSuggestions(fn () => $suggestions->trendingArtworks()),
]), 403);
}
// ── Step 2: full load with all relations ───────────────────────────
$artwork = Artwork::with(['user.profile', 'group.owner.profile', 'uploadedBy.profile', 'primaryAuthor.profile', 'contributors.user.profile', 'categories.contentType', 'categories.parent.contentType', 'tags', 'stats', 'awardStat'])
->where('id', $id)
->public()
->published()
->firstOrFail();
$canonicalSlug = Str::slug((string) ($artwork->slug ?: $artwork->title));
if ($canonicalSlug === '') {
$canonicalSlug = (string) $artwork->id;
}
if ((string) $slug !== $canonicalSlug) {
return redirect()->route('art.show', [
'id' => $artwork->id,
'slug' => $canonicalSlug,
], 301);
}
$thumbMd = ThumbnailPresenter::present($artwork, 'md');
$thumbLg = ThumbnailPresenter::present($artwork, 'lg');
$thumbXl = ThumbnailPresenter::present($artwork, 'xl');
$thumbSq = ThumbnailPresenter::present($artwork, 'sq');
$artworkData = (new ArtworkResource($artwork))->toArray($request);
$groupSummary = null;
if ($artwork->group) {
$artwork->group->loadMissing(['owner.profile', 'recruitmentProfile', 'discoveryMetric', 'members', 'badges']);
$groupSummary = $this->groups->mapGroupCard($artwork->group, $request->user());
}
$canonical = route('art.show', ['id' => $artwork->id, 'slug' => $canonicalSlug]);
$authorName = $artwork->group?->name ?: $artwork->primaryAuthor?->name ?: $artwork->primaryAuthor?->username ?: $artwork->user?->name ?: $artwork->user?->username ?: 'Artist';
$description = Str::limit(trim(strip_tags(html_entity_decode((string) ($artwork->description ?? ''), ENT_QUOTES | ENT_HTML5, 'UTF-8'))), 160, '…');
$meta = [
'title' => sprintf('%s by %s — Skinbase', html_entity_decode((string) $artwork->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'), html_entity_decode((string) $authorName, ENT_QUOTES | ENT_HTML5, 'UTF-8')),
'description' => $description !== '' ? $description : html_entity_decode((string) $artwork->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'canonical' => $canonical,
'og_image' => $thumbXl['url'] ?? $thumbLg['url'] ?? null,
'og_width' => $thumbXl['width'] ?? $thumbLg['width'] ?? null,
'og_height' => $thumbXl['height'] ?? $thumbLg['height'] ?? null,
];
$seo = app(SeoFactory::class)->artwork($artwork, [
'md' => $thumbMd,
'lg' => $thumbLg,
'xl' => $thumbXl,
], $canonical)->toArray();
$categoryIds = $artwork->categories->pluck('id')->filter()->values();
$tagIds = $artwork->tags->pluck('id')->filter()->values();
$related = Artwork::query()
->with(['user', 'group', 'categories.contentType'])
->whereKeyNot($artwork->id)
->public()
->published()
->tap(fn ($builder) => $this->maturity->applyViewerFilter($builder, $request->user()))
->where(function ($query) use ($artwork, $categoryIds, $tagIds): void {
$query->where('user_id', $artwork->user_id);
if ($artwork->group_id) {
$query->orWhere('group_id', $artwork->group_id);
}
if ($categoryIds->isNotEmpty()) {
$query->orWhereHas('categories', function ($categoryQuery) use ($categoryIds): void {
$categoryQuery->whereIn('categories.id', $categoryIds->all());
});
}
if ($tagIds->isNotEmpty()) {
$query->orWhereHas('tags', function ($tagQuery) use ($tagIds): void {
$tagQuery->whereIn('tags.id', $tagIds->all());
});
}
})
->latest('published_at')
->limit(12)
->get()
->map(function (Artwork $item): array {
$itemSlug = Str::slug((string) ($item->slug ?: $item->title));
if ($itemSlug === '') {
$itemSlug = (string) $item->id;
}
$md = ThumbnailPresenter::present($item, 'md');
$lg = ThumbnailPresenter::present($item, 'lg');
return $this->maturity->decoratePayload([
'id' => (int) $item->id,
'title' => html_entity_decode((string) $item->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'author' => html_entity_decode((string) ($item->group?->name ?: $item->user?->name ?: $item->user?->username ?: 'Artist'), ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'url' => route('art.show', ['id' => $item->id, 'slug' => $itemSlug]),
'thumb' => $md['url'] ?? null,
'thumb_srcset' => ($md['url'] ?? '') . ' 640w, ' . ($lg['url'] ?? '') . ' 1280w',
], $item, request()->user());
})
->values()
->all();
// Recursive helper to format a comment and its nested replies
$formatComment = null;
$formatComment = function (ArtworkComment $c) use (&$formatComment): array {
$replies = $c->relationLoaded('approvedReplies') ? $c->approvedReplies : collect();
$user = $c->user;
$userId = (int) ($c->user_id ?? 0);
$avatarHash = $user?->profile?->avatar_hash ?? null;
$canPublishLinks = (int) ($user?->level ?? 1) > 1 && strtolower((string) ($user?->rank ?? 'Newbie')) !== 'newbie';
$rawContent = (string) ($c->raw_content ?? $c->content ?? '');
$renderedContent = $c->rendered_content;
if (! is_string($renderedContent) || trim($renderedContent) === '') {
$renderedContent = $rawContent !== ''
? ContentSanitizer::render($rawContent)
: nl2br(e(strip_tags((string) ($c->content ?? ''))));
}
return [
'id' => $c->id,
'parent_id' => $c->parent_id,
'content' => html_entity_decode((string) $c->content, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
'raw_content' => $c->raw_content ?? $c->content,
'rendered_content' => ContentSanitizer::sanitizeRenderedHtml($renderedContent, $canPublishLinks),
'created_at' => $c->created_at?->toIso8601String(),
'time_ago' => $c->created_at ? Carbon::parse($c->created_at)->diffForHumans() : null,
'user' => [
'id' => $userId,
'name' => $user?->name,
'username' => $user?->username,
'display' => $user?->username ?? $user?->name ?? 'User',
'profile_url' => $user?->username ? '/@' . $user->username : ($userId > 0 ? '/profile/' . $userId : null),
'avatar_url' => AvatarUrl::forUser($userId, $avatarHash, 64),
'level' => (int) ($user?->level ?? 1),
'rank' => (string) ($user?->rank ?? 'Newbie'),
],
'replies' => $replies->map($formatComment)->values()->all(),
];
};
$comments = ArtworkComment::with(['user.profile', 'approvedReplies'])
->where('artwork_id', $artwork->id)
->where('is_approved', true)
->whereNull('parent_id')
->orderBy('created_at')
->limit(500)
->get()
->map($formatComment)
->values()
->all();
return view('artworks.show', [
'artwork' => $artwork,
'artworkData' => $artworkData,
'presentMd' => $thumbMd,
'presentLg' => $thumbLg,
'presentXl' => $thumbXl,
'presentSq' => $thumbSq,
'meta' => $meta,
'seo' => $seo,
'useUnifiedSeo' => true,
'relatedItems' => $related,
'comments' => $comments,
'groupSummary' => $groupSummary,
]);
}
/** Silently catch suggestion query failures so error page never crashes. */
private function safeSuggestions(callable $fn): mixed
{
try {
return $fn();
} catch (\Throwable) {
return collect();
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class AuthHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.auth');
$seo = app(SeoFactory::class)
->collectionPage(
'Signup and Login Help — Skinbase',
'Learn how signup, login, password recovery, verification, and account access work on Skinbase Nova, with clear guidance for common access problems and practical next steps.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/AuthHelpPage', [
'title' => 'Signup & Login Help',
'description' => 'Get clear help for account creation, sign-in, password recovery, verification basics, and common access problems on Skinbase Nova.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'help_profile' => route('help.profile'),
'studio_help' => route('help.studio'),
'groups_help' => route('help.groups'),
'help_account' => route('help.account'),
'help_troubleshooting' => route('help.troubleshooting'),
'login' => route('login'),
'register' => route('register'),
'password_request' => route('password.request'),
'verification_notice' => route('verification.notice'),
'open_studio' => route('studio.index'),
'profile_settings' => route('dashboard.profile'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\BlogPost;
use Illuminate\Http\Request;
use Illuminate\View\View;
/**
* BlogController /blog index + single post.
*/
final class BlogController extends Controller
{
public function index(Request $request): View
{
$posts = BlogPost::published()
->orderByDesc('published_at')
->paginate(12)
->withQueryString();
return view('web.blog.index', [
'posts' => $posts,
'page_title' => 'Blog — Skinbase',
'page_meta_description' => 'News, tutorials and community stories from the Skinbase team.',
'page_canonical' => url('/blog'),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Blog', 'url' => '/blog'],
]),
]);
}
public function show(string $slug): View
{
$post = BlogPost::published()->where('slug', $slug)->firstOrFail();
return view('web.blog.show', [
'post' => $post,
'page_title' => ($post->meta_title ?: $post->title) . ' — Skinbase Blog',
'page_meta_description' => $post->meta_description ?: $post->excerpt ?: '',
'page_canonical' => $post->url,
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Blog', 'url' => '/blog'],
(object) ['name' => $post->title, 'url' => $post->url],
]),
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class BrowseCategoriesController extends Controller
{
public function index(Request $request)
{
$contentTypes = \App\Models\ContentType::with(['rootCategories.children'])->ordered()->get();
$categoriesByType = [];
$categories = collect();
foreach ($contentTypes as $ct) {
$rootCats = $ct->rootCategories;
foreach ($rootCats as $cat) {
$cat->subcategories = $cat->children;
$categories->push($cat);
}
$categoriesByType[$ct->slug] = $rootCats;
}
return view('browse-categories', [
'contentTypes' => $contentTypes,
'categoriesByType' => $categoriesByType,
'categories' => $categories,
]);
}
}

View File

@@ -0,0 +1,493 @@
<?php
namespace App\Http\Controllers\Web;
use App\Models\Category;
use App\Models\ContentType;
use App\Models\Artwork;
use App\Services\ArtworkSearchService;
use App\Services\ArtworkService;
use App\Services\ContentTypes\ContentTypeSlugResolver;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\ThumbnailPresenter;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\Pagination\AbstractPaginator;
use Illuminate\Pagination\AbstractCursorPaginator;
class BrowseGalleryController extends \App\Http\Controllers\Controller
{
/**
* Meilisearch sort-field arrays per sort alias.
* First element is primary sort; subsequent elements are tie-breakers.
*/
private const SORT_MAP = [
// ── Nova sort aliases ─────────────────────────────────────────────────
// trending_score_24h only covers artworks ≤ 7 days old; use 7d score
// and favorites_count as fallbacks so older artworks don't all tie at 0.
'trending' => ['trending_score_24h:desc', 'trending_score_7d:desc', 'favorites_count:desc', 'created_at:desc'],
// "New & Hot": 30-day trending window surfaces recently-active artworks.
'fresh' => ['trending_score_7d:desc', 'favorites_count:desc', 'created_at:desc'],
'top-rated' => ['awards_received_count:desc', 'favorites_count:desc'],
'favorited' => ['favorites_count:desc', 'trending_score_24h:desc'],
'downloaded' => ['downloads_count:desc', 'trending_score_24h:desc'],
'oldest' => ['created_at:asc'],
// ── Legacy aliases (backward compat) ──────────────────────────────────
'latest' => ['created_at:desc'],
'popular' => ['views:desc', 'favorites_count:desc'],
'liked' => ['likes:desc', 'favorites_count:desc'],
'downloads' => ['downloads:desc', 'downloads_count:desc'],
];
/**
* Cache TTL (seconds) per sort alias.
* trending 5 min
* fresh 2 min
* top-rated 10 min
* others 5 min
*/
private const SORT_TTL_MAP = [
'trending' => 300,
'fresh' => 120,
'top-rated' => 600,
'favorited' => 300,
'downloaded' => 300,
'oldest' => 600,
'latest' => 120,
'popular' => 300,
'liked' => 300,
'downloads' => 300,
];
/** Human-readable sort options passed to every gallery view. */
private const SORT_OPTIONS = [
['value' => 'trending', 'label' => '🔥 Trending'],
['value' => 'fresh', 'label' => '🆕 Fresh'],
['value' => 'top-rated', 'label' => '⭐ Top Rated'],
['value' => 'favorited', 'label' => '❤️ Most Favorited'],
['value' => 'downloaded', 'label' => '⬇ Most Downloaded'],
['value' => 'oldest', 'label' => '📅 Oldest'],
];
public function __construct(
private ArtworkService $artworks,
private ArtworkSearchService $search,
private ContentTypeSlugResolver $contentTypeResolver,
private ArtworkMaturityService $maturity,
) {
}
public function browse(Request $request)
{
$sort = $this->resolveSort($request, 'trending');
$perPage = $this->resolvePerPage($request);
$page = (int) $request->query('page', 1);
$ttl = self::SORT_TTL_MAP[$sort] ?? 300;
$artworks = Cache::remember(
"browse.all.catalog-visible.v2.{$sort}.{$page}",
$ttl,
fn () => $this->search->searchWithThumbnailPreference([
'filter' => 'is_public = true AND is_approved = true',
'sort' => self::SORT_MAP[$sort] ?? ['created_at:desc'],
], $perPage, false, $page)
);
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
$seo = $this->buildPaginationSeo($request, url('/browse'), $artworks);
$mainCategories = $this->mainCategories();
return view('gallery.index', [
'gallery_type' => 'browse',
'mainCategories' => $mainCategories,
'subcategories' => $mainCategories,
'contentType' => null,
'category' => null,
'artworks' => $artworks,
'current_sort' => $sort,
'sort_options' => self::SORT_OPTIONS,
'hero_title' => 'Browse Artworks',
'hero_description' => 'List of all uploaded artworks across Skins, Wallpapers, Photography, and Other.',
'breadcrumbs' => collect([(object) ['name' => 'Explore', 'url' => '/browse']]),
'page_title' => 'Browse Uploaded Artworks - Photography, Wallpapers and Skins at SkinBase',
'page_meta_description' => "Browse Uploaded Photography, Wallpapers and Skins to one of the world's oldest online social community for artists and art enthusiasts.",
'page_meta_keywords' => 'photography, wallpapers, skins, stock, browse, social, community, artist, picture, photo',
'page_canonical' => $seo['canonical'],
'page_rel_prev' => $seo['prev'],
'page_rel_next' => $seo['next'],
'page_robots' => 'index,follow',
]);
}
public function content(Request $request, string $contentTypeSlug, ?string $path = null)
{
$requestedSlug = strtolower($contentTypeSlug);
$resolution = $this->contentTypeResolver->resolve($requestedSlug);
if (! $resolution->found() || $resolution->contentType === null) {
abort(404);
}
$contentType = $resolution->contentType;
$contentSlug = strtolower((string) $contentType->slug);
if ($resolution->requiresRedirect()) {
return $this->redirectToContentTypePath($request, $contentSlug, $path, 301);
}
// Default sort: trending (not chronological)
$sort = $this->resolveSort($request, 'trending');
$perPage = $this->resolvePerPage($request);
$page = (int) $request->query('page', 1);
$ttl = self::SORT_TTL_MAP[$sort] ?? 300;
$mainCategories = $this->mainCategories();
$rootCategories = $contentType->rootCategories()->orderBy('sort_order')->orderBy('name')->get();
$normalizedPath = trim((string) $path, '/');
if ($normalizedPath === '') {
$artworks = Cache::remember(
"gallery.ct.catalog-visible.v2.{$contentSlug}.{$sort}.{$page}",
$ttl,
fn () => $this->search->searchWithThumbnailPreference([
'filter' => 'is_public = true AND is_approved = true AND content_type = "' . $contentSlug . '"',
'sort' => self::SORT_MAP[$sort] ?? ['created_at:desc'],
], $perPage, false, $page)
);
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
$seo = $this->buildPaginationSeo($request, url('/' . $contentSlug), $artworks);
return view('gallery.index', [
'gallery_type' => 'content-type',
'mainCategories' => $mainCategories,
'subcategories' => $rootCategories,
'contentType' => $contentType,
'category' => null,
'artworks' => $artworks,
'current_sort' => $sort,
'sort_options' => self::SORT_OPTIONS,
'hero_title' => $contentType->name,
'hero_description' => $contentType->description ?? ($contentType->name . ' artworks on Skinbase.'),
'breadcrumbs' => collect([
(object) ['name' => 'Explore', 'url' => '/browse'],
(object) ['name' => $contentType->name, 'url' => '/' . $contentSlug],
]),
'page_title' => $contentType->name . ' Skinbase Nova',
'page_meta_description' => $contentType->description ?? ('Discover the best ' . $contentType->name . ' artworks on Skinbase'),
'page_meta_keywords' => strtolower($contentType->slug) . ', skinbase, artworks, wallpapers, skins, photography',
'page_canonical' => $seo['canonical'],
'page_rel_prev' => $seo['prev'],
'page_rel_next' => $seo['next'],
'page_robots' => 'index,follow',
]);
}
$segments = array_values(array_filter(explode('/', $normalizedPath)));
$category = Category::findByPath($contentSlug, $segments);
if (! $category) {
abort(404);
}
$categorySlugs = $this->categoryFilterSlugs($category);
$categoryFilter = collect($categorySlugs)
->map(fn (string $slug) => 'category = "' . addslashes($slug) . '"')
->implode(' OR ');
$artworks = Cache::remember(
'gallery.cat.catalog-visible.v2.' . md5($contentSlug . '|' . implode('|', $categorySlugs)) . ".{$sort}.{$page}",
$ttl,
fn () => $this->search->searchWithThumbnailPreference([
'filter' => 'is_public = true AND is_approved = true AND (' . $categoryFilter . ')',
'sort' => self::SORT_MAP[$sort] ?? ['created_at:desc'],
], $perPage, false, $page)
);
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
$seo = $this->buildPaginationSeo($request, url('/' . $contentSlug . '/' . strtolower($category->full_slug_path)), $artworks);
$navigationCategory = $category->parent ?: $category;
$subcategories = $navigationCategory->children()->orderBy('sort_order')->orderBy('name')->get();
if ($subcategories->isEmpty()) {
$subcategories = $rootCategories;
}
$breadcrumbs = collect(array_merge([
(object) [
'name' => 'Explore',
'url' => '/browse',
],
(object) [
'name' => $contentType->name,
'url' => '/' . $contentSlug,
],
], $category->breadcrumbs))
->map(function ($crumb) {
return (object) [
'name' => $crumb->name,
'url' => $crumb->url,
];
});
return view('gallery.index', [
'gallery_type' => 'category',
'mainCategories' => $mainCategories,
'subcategories' => $subcategories,
'subcategory_parent' => $navigationCategory,
'contentType' => $contentType,
'category' => $category,
'artworks' => $artworks,
'current_sort' => $sort,
'sort_options' => self::SORT_OPTIONS,
'hero_title' => $category->name,
'hero_description' => $category->description ?? ($contentType->name . ' artworks on Skinbase.'),
'breadcrumbs' => $breadcrumbs,
'page_title' => $category->name . ' Skinbase Nova',
'page_meta_description' => $category->description ?? ('Discover the best ' . $category->name . ' ' . $contentType->name . ' artworks on Skinbase'),
'page_meta_keywords' => strtolower($contentType->slug) . ', skinbase, artworks, wallpapers, skins, photography',
'page_canonical' => $seo['canonical'],
'page_rel_prev' => $seo['prev'],
'page_rel_next' => $seo['next'],
'page_robots' => 'index,follow',
]);
}
public function showArtwork(...$params)
{
$req = request();
$pathSegments = array_values(array_filter(explode('/', trim($req->path(), '/'))));
$contentTypeSlug = $params[0] ?? ($pathSegments[0] ?? null);
$categoryPath = $params[1] ?? null;
$artwork = $params[2] ?? null;
// If artwork wasn't provided (some route invocations supply fewer args),
// derive it from the request path's last segment.
if ($artwork === null) {
$artwork = end($pathSegments) ?: null;
}
$contentTypeSlug = strtolower((string) $contentTypeSlug);
$categoryPath = $categoryPath !== null ? trim((string) $categoryPath, '/') : (isset($pathSegments[1]) ? implode('/', array_slice($pathSegments, 1, max(0, count($pathSegments) - 2))) : '');
$resolution = $this->contentTypeResolver->resolve($contentTypeSlug);
if (! $resolution->found() || $resolution->contentType === null) {
abort(404);
}
$resolvedContentTypeSlug = strtolower((string) $resolution->contentType->slug);
// Normalize artwork param if route-model binding returned an Artwork model
$artworkSlug = $artwork instanceof Artwork ? (string) $artwork->slug : (string) $artwork;
if ($resolution->requiresRedirect()) {
$path = trim($categoryPath . '/' . $artworkSlug, '/');
return $this->redirectToContentTypePath($req, $resolvedContentTypeSlug, $path, 301);
}
return app(\App\Http\Controllers\ArtworkController::class)->show(
$req,
$resolvedContentTypeSlug,
$categoryPath,
$artworkSlug
);
}
private function presentArtwork(Artwork $artwork): object
{
$primaryCategory = $artwork->categories->sortBy('sort_order')->first();
$present = ThumbnailPresenter::present($artwork, 'md');
$group = $artwork->group;
$isGroupPublisher = $group !== null;
$avatarUrl = $isGroupPublisher
? $group->avatarUrl()
: \App\Support\AvatarUrl::forUser(
(int) ($artwork->user_id ?? 0),
$artwork->user?->profile?->avatar_hash ?? null,
64
);
$displayName = $isGroupPublisher ? ($group->name ?? 'Skinbase') : ($artwork->user?->name ?? 'Skinbase');
$username = $isGroupPublisher ? '' : ($artwork->user?->username ?? '');
$profileUrl = $isGroupPublisher ? $group->publicUrl() : ($username !== '' ? '/@' . $username : null);
return (object) $this->maturity->decoratePayload([
'id' => $artwork->id,
'name' => $artwork->title,
'content_type_name' => $primaryCategory?->contentType?->name ?? '',
'content_type_slug' => $primaryCategory?->contentType?->slug ?? '',
'category_name' => $primaryCategory->name ?? '',
'category_slug' => $primaryCategory->slug ?? '',
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'uname' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
'published_as_type' => $isGroupPublisher ? 'group' : 'user',
'publisher' => [
'type' => $isGroupPublisher ? 'group' : 'user',
'name' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
],
'published_at' => $artwork->published_at,
'width' => $artwork->width ?? null,
'height' => $artwork->height ?? null,
], $artwork, request()->user());
}
/**
* Build the category slug filter set for a gallery page.
* Includes the current category and all descendant subcategories.
*
* @return array<int, string>
*/
private function categoryFilterSlugs(Category $category): array
{
$category->loadMissing('descendants');
$slugs = [];
$stack = [$category];
while ($stack !== []) {
/** @var Category $current */
$current = array_pop($stack);
if (! empty($current->slug)) {
$slugs[] = Str::lower($current->slug);
}
foreach ($current->children as $child) {
$child->loadMissing('descendants');
$stack[] = $child;
}
}
return array_values(array_unique($slugs));
}
private function resolvePerPage(Request $request): int
{
$limit = (int) $request->query('limit', 0);
$perPage = (int) $request->query('per_page', 0);
// Spec §8: recommended 24 per page on category/gallery pages
$value = $limit > 0 ? $limit : ($perPage > 0 ? $perPage : 24);
return max(12, min($value, 80));
}
/**
* Validate and return the requested sort alias, falling back to $default.
* Only allows keys present in SORT_MAP.
*/
private function resolveSort(Request $request, string $default = 'trending'): string
{
$requested = (string) $request->query('sort', $default);
return array_key_exists($requested, self::SORT_MAP) ? $requested : $default;
}
private function mainCategories(): Collection
{
return $this->contentTypeResolver
->publicContentTypes()
->map(function (ContentType $type) {
return (object) [
'id' => $type->id,
'name' => $type->name,
'slug' => $type->slug,
'url' => '/' . strtolower($type->slug),
];
});
}
private function redirectToContentTypePath(Request $request, string $contentTypeSlug, ?string $path = null, int $status = 301): RedirectResponse
{
$target = url('/' . trim($contentTypeSlug . '/' . trim((string) $path, '/'), '/'));
$queryString = $request->getQueryString();
if ($queryString) {
$target .= '?' . $queryString;
}
return redirect()->to($target, $status);
}
private function buildPaginationSeo(Request $request, string $canonicalBaseUrl, mixed $paginator): array
{
$canonicalQuery = $request->query();
unset($canonicalQuery['grid']);
if (($canonicalQuery['page'] ?? null) !== null && (int) $canonicalQuery['page'] <= 1) {
unset($canonicalQuery['page']);
}
$canonical = $canonicalBaseUrl;
if ($canonicalQuery !== []) {
$canonical .= '?' . http_build_query($canonicalQuery);
}
$prev = null;
$next = null;
if ($paginator instanceof AbstractPaginator || $paginator instanceof AbstractCursorPaginator) {
$prev = $this->stripQueryParamFromUrl($paginator->previousPageUrl(), 'grid');
$next = $this->stripQueryParamFromUrl($paginator->nextPageUrl(), 'grid');
}
return [
'canonical' => $canonical,
'prev' => $prev,
'next' => $next,
];
}
private function stripQueryParamFromUrl(?string $url, string $queryParam): ?string
{
if ($url === null || $url === '') {
return null;
}
$parts = parse_url($url);
if (!is_array($parts)) {
return $url;
}
$query = [];
if (!empty($parts['query'])) {
parse_str($parts['query'], $query);
unset($query[$queryParam]);
}
$rebuilt = '';
if (isset($parts['scheme'])) {
$rebuilt .= $parts['scheme'] . '://';
}
if (isset($parts['user'])) {
$rebuilt .= $parts['user'];
if (isset($parts['pass'])) {
$rebuilt .= ':' . $parts['pass'];
}
$rebuilt .= '@';
}
if (isset($parts['host'])) {
$rebuilt .= $parts['host'];
}
if (isset($parts['port'])) {
$rebuilt .= ':' . $parts['port'];
}
$rebuilt .= $parts['path'] ?? '';
if ($query !== []) {
$rebuilt .= '?' . http_build_query($query);
}
if (isset($parts['fragment'])) {
$rebuilt .= '#' . $parts['fragment'];
}
return $rebuilt;
}
}

View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\BugReport;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
/**
* BugReportController /bug-report
*
* GET /bug-report show form (guests see a login prompt)
* POST /bug-report authenticated users submit a report
*/
final class BugReportController extends Controller
{
public function show(Request $request): View
{
return view('web.bug-report', [
'page_title' => 'Bug Report — Skinbase',
'page_meta_description' => 'Submit a bug report or suggestion to the Skinbase team.',
'page_canonical' => url('/bug-report'),
'hero_title' => 'Bug Report',
'hero_description' => 'Found something broken? Submit a report and our team will look into it.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Bug Report', 'url' => '/bug-report'],
]),
'success' => session('bug_report_success', false),
'center_content' => true,
'center_max' => '3xl',
]);
}
public function submit(Request $request): RedirectResponse
{
$validated = $request->validate([
'subject' => ['required', 'string', 'max:255'],
'description' => ['required', 'string', 'max:5000'],
]);
BugReport::create([
'user_id' => $request->user()->id,
'subject' => $validated['subject'],
'description' => $validated['description'],
'ip_address' => $request->ip(),
'user_agent' => substr($request->userAgent() ?? '', 0, 512),
'status' => 'open',
]);
return redirect()->route('bug-report')->with('bug_report_success', true);
}
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class CardsHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.cards');
$seo = app(SeoFactory::class)
->collectionPage(
'Cards Help — Skinbase',
'Learn what Cards are on Skinbase Nova, how they differ from artworks, posts, and collections, and how to create, publish, and use them effectively in personal and Group workflows.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/CardsHelpPage', [
'title' => 'Cards Help',
'description' => 'Understand Cards as a distinct creative format on Skinbase Nova, with guidance for creation, publishing, ownership, design quality, and real-world use cases.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'studio_help' => route('help.studio'),
'upload_help' => route('help.upload'),
'groups_help' => route('help.groups'),
'open_studio' => route('studio.index'),
'studio_cards' => route('studio.cards.index'),
'create_card' => route('studio.cards.create'),
'cards_index' => route('cards.index'),
'help_profile' => route('help.profile'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,135 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\ArtworkService;
use App\Models\Category;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class CategoryController extends Controller
{
protected ArtworkService $artworkService;
public function __construct(ArtworkService $artworkService)
{
$this->artworkService = $artworkService;
}
public function index(Request $request)
{
return $this->browseCategories();
}
public function show(Request $request, $id, $slug = null, $group = null)
{
$path = trim($request->path(), '/');
$segments = array_values(array_filter(explode('/', $path)));
if (count($segments) < 2 || strtolower($segments[0]) !== 'category') {
return view('shared.placeholder');
}
$parts = array_slice($segments, 1);
$first = $parts[0] ?? null;
if ($first !== null && ctype_digit((string) $first)) {
try {
$category = Category::findOrFail((int) $first);
$contentTypeSlug = $category->contentType->slug ?? null;
$canonical = '/' . strtolower($contentTypeSlug) . '/' . $category->full_slug_path;
return redirect($canonical, 301);
} catch (ModelNotFoundException $e) {
abort(404);
}
}
$contentTypeSlug = array_shift($parts);
$slugs = array_merge([$contentTypeSlug], $parts);
$perPage = (int) $request->get('per_page', 40);
$sort = (string) $request->get('sort', 'latest');
try {
$artworks = $this->artworkService->getArtworksByCategoryPath($slugs, $perPage, $sort);
} catch (ModelNotFoundException $e) {
abort(404);
}
try {
$category = Category::whereHas('contentType', function ($q) use ($contentTypeSlug) {
$q->where('slug', strtolower($contentTypeSlug));
})->whereNull('parent_id')->where('slug', strtolower($parts[0] ?? ''))->first();
if ($category && count($parts) > 1) {
$cur = $category;
foreach (array_slice($parts, 1) as $slugPart) {
$cur = $cur->children()->where('slug', strtolower($slugPart))->first();
if (! $cur) {
abort(404);
}
}
$category = $cur;
}
} catch (\Throwable $e) {
$category = null;
}
if (! $category) {
abort(404);
}
$subcategories = $category->children()->orderBy('sort_order')->orderBy('name')->get();
$breadcrumbs = collect(array_merge([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Explore', 'url' => '/browse'],
(object) ['name' => $category->contentType->name, 'url' => '/' . strtolower((string) $category->contentType->slug)],
], collect($category->breadcrumbs)->map(fn ($crumb) => (object) [
'name' => $crumb->name,
'url' => $crumb->url,
])->all()));
$page_title = sprintf('%s — %s — Skinbase', $category->name, $category->contentType->name);
$page_meta_description = $category->description ?? ($category->contentType->name . ' artworks on Skinbase');
$page_meta_keywords = strtolower($category->contentType->slug) . ', skinbase, artworks, wallpapers, skins, photography';
$page_canonical = url()->current();
return view('web.category', compact(
'page_title',
'page_meta_description',
'page_meta_keywords',
'page_canonical',
'breadcrumbs',
'group',
'category',
'subcategories',
'artworks'
));
}
public function browseCategories()
{
$pageTitle = 'All Categories Wallpapers, Skins & Digital Art | Skinbase';
$pageDescription = 'Browse all categories on Skinbase including wallpapers, skins, themes, and digital art collections.';
return view('web.categories', [
'page_title' => $pageTitle,
'page_meta_description' => $pageDescription,
'page_canonical' => url('/categories'),
'structured_data' => [
'@context' => 'https://schema.org',
'@type' => 'CollectionPage',
'name' => 'Categories',
'description' => $pageDescription,
'url' => url('/categories'),
'isPartOf' => [
'@type' => 'WebSite',
'name' => 'Skinbase',
'url' => url('/'),
],
],
]);
}
}

View File

@@ -0,0 +1,261 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Collection;
use App\Services\CollectionCampaignService;
use App\Services\CollectionDiscoveryService;
use App\Services\CollectionPartnerProgramService;
use App\Services\CollectionRecommendationService;
use App\Services\CollectionSearchService;
use App\Services\CollectionService;
use App\Services\CollectionSurfaceService;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
class CollectionDiscoveryController extends Controller
{
public function __construct(
private readonly CollectionDiscoveryService $discovery,
private readonly CollectionService $collections,
private readonly CollectionRecommendationService $recommendations,
private readonly CollectionSearchService $search,
private readonly CollectionSurfaceService $surfaces,
private readonly CollectionCampaignService $campaigns,
private readonly CollectionPartnerProgramService $partnerPrograms,
) {
}
public function search(Request $request)
{
$filters = $request->validate([
'q' => ['nullable', 'string', 'max:120'],
'type' => ['nullable', 'string', 'max:40'],
'category' => ['nullable', 'string', 'max:80'],
'style' => ['nullable', 'string', 'max:80'],
'theme' => ['nullable', 'string', 'max:80'],
'color' => ['nullable', 'string', 'max:80'],
'quality_tier' => ['nullable', 'string', 'max:40'],
'lifecycle_state' => ['nullable', 'string', 'max:40'],
'mode' => ['nullable', 'string', 'max:40'],
'campaign_key' => ['nullable', 'string', 'max:80'],
'program_key' => ['nullable', 'string', 'max:80'],
'workflow_state' => ['nullable', 'string', 'max:40'],
'health_state' => ['nullable', 'string', 'max:40'],
'sort' => ['nullable', 'in:trending,recent,quality,evergreen'],
]);
$results = $this->search->publicSearch($filters, (int) config('collections.v5.search.public_per_page', 18));
$seo = app(SeoFactory::class)->collectionListing(
'Search Collections — Skinbase Nova',
filled($filters['q'] ?? null)
? sprintf('Search results for "%s" across public Skinbase Nova collections.', $filters['q'])
: 'Browse public collections using filters for category, style, theme, color, quality tier, freshness, and programming metadata.',
$request->fullUrl(),
null,
false,
)->toArray();
return Inertia::render('Collection/CollectionFeaturedIndex', [
'eyebrow' => 'Search',
'title' => 'Search collections',
'description' => filled($filters['q'] ?? null)
? sprintf('Search results for "%s" across public Skinbase Nova collections.', $filters['q'])
: 'Browse public collections using filters for category, style, theme, color, quality tier, freshness, and programming metadata.',
'seo' => $seo,
'collections' => $this->collections->mapCollectionCardPayloads($results->items(), false, $request->user()),
'communityCollections' => [],
'editorialCollections' => [],
'recentCollections' => [],
'trendingCollections' => [],
'seasonalCollections' => [],
'campaign' => null,
'search' => [
'filters' => $filters,
'options' => $this->search->publicFilterOptions(),
'meta' => [
'current_page' => $results->currentPage(),
'last_page' => $results->lastPage(),
'per_page' => $results->perPage(),
'total' => $results->total(),
],
'links' => [
'next' => $results->nextPageUrl(),
'prev' => $results->previousPageUrl(),
],
],
])->rootView('collections');
}
public function featured(Request $request)
{
$featuredCollections = $this->surfaces->resolveSurfaceItems('discover.featured_collections', (int) config('collections.discovery.featured_limit', 18));
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Discovery',
title: 'Featured collections',
description: 'A rotating set of standout galleries from across Skinbase Nova. Some are meticulously hand-sequenced. Others are smart collections that stay fresh as the creator publishes new work.',
collections: $featuredCollections->isNotEmpty() ? $featuredCollections : $this->discovery->publicFeaturedCollections((int) config('collections.discovery.featured_limit', 18)),
communityCollections: $this->discovery->publicCollectionsByType(Collection::TYPE_COMMUNITY, 6),
editorialCollections: $this->discovery->publicCollectionsByType(Collection::TYPE_EDITORIAL, 6),
recentCollections: $this->discovery->publicRecentCollections(6),
trendingCollections: $this->discovery->publicTrendingCollections(6),
seasonalCollections: $this->discovery->publicSeasonalCollections(6),
);
}
public function recommended(Request $request)
{
$collections = $this->recommendations->recommendedForUser($request->user(), (int) config('collections.discovery.featured_limit', 18));
return $this->renderIndex(
viewer: $request->user(),
eyebrow: $request->user() ? 'For You' : 'Discovery',
title: $request->user() ? 'Recommended collections' : 'Collections worth exploring',
description: $request->user()
? 'A safe, public-only recommendation feed based on the collections you save, follow, and engage with. Private, restricted, and unlisted sets are excluded.'
: 'A safe public collection mix built from current momentum, editorial quality, and community interest.',
collections: $collections,
recentCollections: $this->discovery->publicRecentCollections(6),
trendingCollections: $this->discovery->publicTrendingCollections(6),
editorialCollections: $this->discovery->publicCollectionsByType(Collection::TYPE_EDITORIAL, 6),
);
}
public function trending(Request $request)
{
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Trending',
title: 'Trending collections',
description: 'The collections drawing the strongest blend of follows, likes, saves, comments, and recent activity right now.',
collections: $this->discovery->publicTrendingCollections((int) config('collections.discovery.featured_limit', 18)),
recentCollections: $this->discovery->publicRecentlyActiveCollections(6),
);
}
public function editorial(Request $request)
{
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Editorial',
title: 'Editorial collections',
description: 'Staff picks, campaign showcases, and premium curated sets with stronger scheduling and presentation rules.',
collections: $this->discovery->publicCollectionsByType(Collection::TYPE_EDITORIAL, (int) config('collections.discovery.featured_limit', 18)),
);
}
public function community(Request $request)
{
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Community',
title: 'Community collections',
description: 'Collaborative and submission-friendly showcases that celebrate both the curator and the creators featured inside them.',
collections: $this->discovery->publicCollectionsByType(Collection::TYPE_COMMUNITY, (int) config('collections.discovery.featured_limit', 18)),
);
}
public function seasonal(Request $request)
{
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Seasonal',
title: 'Seasonal and event collections',
description: 'Collections prepared for campaigns, seasonal spotlights, and event-driven showcases with dedicated metadata.',
collections: $this->discovery->publicSeasonalCollections((int) config('collections.discovery.featured_limit', 18)),
editorialCollections: $this->discovery->publicCollectionsByType(Collection::TYPE_EDITORIAL, 6),
communityCollections: $this->discovery->publicCollectionsByType(Collection::TYPE_COMMUNITY, 6),
);
}
public function campaign(Request $request, string $campaignKey)
{
$landing = $this->campaigns->publicLanding($campaignKey, (int) config('collections.discovery.featured_limit', 18));
$campaign = $landing['campaign'];
abort_if(collect($landing['collections'])->isEmpty(), 404);
return $this->renderIndex(
viewer: $request->user(),
eyebrow: 'Campaign',
title: $campaign['label'],
description: $campaign['description'],
collections: $landing['collections'],
communityCollections: $landing['community_collections'],
editorialCollections: $landing['editorial_collections'],
recentCollections: $landing['recent_collections'],
trendingCollections: $landing['trending_collections'],
campaign: $campaign,
);
}
public function program(Request $request, string $programKey)
{
$landing = $this->partnerPrograms->publicLanding($programKey, (int) config('collections.discovery.featured_limit', 18));
$program = $landing['program'];
abort_if(! $program || collect($landing['collections'])->isEmpty(), 404);
$seo = app(SeoFactory::class)->collectionListing(
sprintf('%s — Skinbase Nova', $program['label']),
$program['description'],
route('collections.program.show', ['programKey' => $program['key']]),
)->toArray();
return Inertia::render('Collection/CollectionFeaturedIndex', [
'eyebrow' => 'Program',
'title' => $program['label'],
'description' => $program['description'],
'seo' => $seo,
'collections' => $this->collections->mapCollectionCardPayloads($landing['collections'], false, $request->user()),
'communityCollections' => $this->collections->mapCollectionCardPayloads($landing['community_collections'] ?? collect(), false, $request->user()),
'editorialCollections' => $this->collections->mapCollectionCardPayloads($landing['editorial_collections'] ?? collect(), false, $request->user()),
'recentCollections' => $this->collections->mapCollectionCardPayloads($landing['recent_collections'] ?? collect(), false, $request->user()),
'trendingCollections' => [],
'seasonalCollections' => [],
'campaign' => null,
'program' => $program,
])->rootView('collections');
}
private function renderIndex(
$viewer,
string $eyebrow,
string $title,
string $description,
$collections,
$communityCollections = null,
$editorialCollections = null,
$recentCollections = null,
$trendingCollections = null,
$seasonalCollections = null,
$campaign = null,
) {
$seo = app(SeoFactory::class)->collectionListing(
sprintf('%s — Skinbase Nova', $title),
$description,
url()->current(),
)->toArray();
return Inertia::render('Collection/CollectionFeaturedIndex', [
'eyebrow' => $eyebrow,
'title' => $title,
'description' => $description,
'seo' => $seo,
'collections' => $this->collections->mapCollectionCardPayloads($collections, false, $viewer),
'communityCollections' => $this->collections->mapCollectionCardPayloads($communityCollections ?? collect(), false, $viewer),
'editorialCollections' => $this->collections->mapCollectionCardPayloads($editorialCollections ?? collect(), false, $viewer),
'recentCollections' => $this->collections->mapCollectionCardPayloads($recentCollections ?? collect(), false, $viewer),
'trendingCollections' => $this->collections->mapCollectionCardPayloads($trendingCollections ?? collect(), false, $viewer),
'seasonalCollections' => $this->collections->mapCollectionCardPayloads($seasonalCollections ?? collect(), false, $viewer),
'campaign' => $campaign,
])->rootView('collections');
}
}

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\CommunityActivityService;
use Illuminate\Http\Request;
final class CommunityActivityController extends Controller
{
public function __construct(private readonly CommunityActivityService $activityService)
{
}
public function index(Request $request)
{
$filter = $this->resolveFilter($request);
if ($this->activityService->requiresAuthentication($filter) && ! $request->user()) {
$filter = 'all';
}
$feed = $this->activityService->getFeed(
viewer: $request->user(),
filter: $filter,
page: 1,
perPage: CommunityActivityService::DEFAULT_PER_PAGE,
actorUserId: $request->filled('user_id') ? (int) $request->query('user_id') : null,
);
return view('web.comments.latest', [
'page_title' => 'Community Activity',
'props' => [
'initialActivities' => $feed['data'],
'initialMeta' => $feed['meta'],
'initialFilter' => $feed['filter'],
'initialUserId' => $request->filled('user_id') ? (int) $request->query('user_id') : null,
'isAuthenticated' => (bool) $request->user(),
],
'initialFilter' => $feed['filter'],
'initialUserId' => $request->filled('user_id') ? (int) $request->query('user_id') : null,
]);
}
private function resolveFilter(Request $request): string
{
if ($request->filled('type') && ! $request->filled('filter')) {
return (string) $request->query('type', 'all');
}
if ($request->boolean('following') && ! $request->filled('filter')) {
return 'following';
}
return (string) $request->query('filter', 'all');
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\ArtworkService;
use App\Services\Maturity\ArtworkMaturityService;
use Illuminate\Http\Request;
class DailyUploadsController extends Controller
{
protected ArtworkService $artworks;
public function __construct(ArtworkService $artworks, private readonly ArtworkMaturityService $maturity)
{
$this->artworks = $artworks;
}
public function index(Request $request)
{
$isAjax = $request->boolean('ajax');
$datum = $request->query('datum');
if ($isAjax && $datum) {
$arts = $this->fetchByDate($datum);
return view('web.partials.daily-uploads-grid', ['arts' => $arts])->render();
}
$dates = [];
for ($x = 0; $x > -15; $x--) {
$ts = strtotime(sprintf('%+d days', $x));
$dates[] = [
'iso' => date('Y-m-d', $ts),
'label' => date('d. F Y', $ts),
];
}
$recent = $this->fetchRecent();
return view('web.daily-uploads', [
'dates' => $dates,
'recent' => $recent,
'page_title' => 'Daily Uploads',
]);
}
private function fetchByDate(string $date)
{
$ars = Artwork::public()
->published()
->whereDate('published_at', $date)
->orderByDesc('published_at')
->with(['user:id,name', 'categories' => function ($q) {
$q->select('categories.id', 'categories.name', 'categories.sort_order');
}])
->get();
return $this->prepareArts($ars);
}
private function fetchRecent()
{
$start = now()->subDays(7)->startOfDay();
$ars = Artwork::public()
->published()
->where('published_at', '>=', $start)
->orderByDesc('published_at')
->with(['user:id,name', 'categories' => function ($q) {
$q->select('categories.id', 'categories.name', 'categories.sort_order');
}])
->get();
return $this->prepareArts($ars);
}
private function prepareArts($ars)
{
$items = $ars->map(function (Artwork $ar): array {
$primaryCategory = $ar->categories->sortBy('sort_order')->first();
$present = \App\Services\ThumbnailPresenter::present($ar, 'md');
return $this->maturity->decoratePayload([
'id' => $ar->id,
'name' => $ar->title,
'thumb' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'gid_num' => $primaryCategory ? ((int) $primaryCategory->id % 5) * 5 : 0,
'category_name' => $primaryCategory->name ?? '',
'uname' => $ar->user->name ?? 'Skinbase',
], $ar, request()->user());
})->values()->all();
return collect($this->maturity->filterPayloadItems($items, request()->user()))
->map(static fn (array $item): object => (object) $item)
->values();
}
}

View File

@@ -0,0 +1,755 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\CommunityActivityService;
use App\Services\ArtworkSearchService;
use App\Services\ArtworkService;
use App\Services\EarlyGrowth\AdaptiveTimeWindow;
use App\Services\EarlyGrowth\GridFiller;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\Recommendations\RecommendationFeedResolver;
use App\Services\UserSuggestionService;
use App\Services\ThumbnailPresenter;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* DiscoverController
*
* Powers the /discover/* discovery pages:
* - /discover/trending most viewed in last 7 days
* - /discover/fresh latest uploads (replaces /uploads/latest)
* - /discover/top-rated highest favourite count
* - /discover/most-downloaded most downloaded all-time
* - /discover/on-this-day published on this calendar day in previous years
* - /discover/for-you personalised feed (auth required)
*/
final class DiscoverController extends Controller
{
public function __construct(
private readonly ArtworkService $artworkService,
private readonly ArtworkSearchService $searchService,
private readonly AdaptiveTimeWindow $timeWindow,
private readonly RecommendationFeedResolver $feedResolver,
private readonly GridFiller $gridFiller,
private readonly CommunityActivityService $communityActivity,
private readonly UserSuggestionService $userSuggestions,
private readonly ArtworkMaturityService $maturity,
) {}
// ─── /discover/trending ──────────────────────────────────────────────────
public function trending(Request $request)
{
$perPage = 24;
$windowDays = $this->timeWindow->getTrendingWindowDays(30);
try {
$results = $this->searchService->discoverTrending($perPage);
} catch (\Throwable) {
$results = $this->fallbackTrendingFromDatabase($perPage, $windowDays);
}
if ($this->paginatorIsEmpty($results)) {
$results = $this->fallbackTrendingFromDatabase($perPage, $windowDays);
}
$this->hydrateDiscoverSearchResults($results);
return view('web.discover.index', [
'artworks' => $results,
'page_title' => 'Trending Artworks',
'section' => 'trending',
'description' => 'The most-viewed artworks on Skinbase over the past 7 days.',
'icon' => 'fa-fire',
]);
}
// ─── /discover/rising ────────────────────────────────────────────────────
public function rising(Request $request)
{
$perPage = 24;
$windowDays = $this->timeWindow->getTrendingWindowDays(30);
try {
$results = $this->searchService->discoverRising($perPage);
} catch (\Throwable) {
$results = $this->fallbackRisingFromDatabase($perPage, $windowDays);
}
if ($this->paginatorIsEmpty($results)) {
$results = $this->fallbackRisingFromDatabase($perPage, $windowDays);
}
if ($this->paginatorHasNoRisingMomentum($results)) {
$results = $this->fallbackRisingLowSignalFromDatabase($perPage, $windowDays);
}
$this->hydrateDiscoverSearchResults($results);
return view('web.discover.index', [
'artworks' => $results,
'page_title' => 'Rising Now',
'section' => 'rising',
'description' => 'Fastest growing artworks right now.',
'icon' => 'fa-rocket',
]);
}
// ─── /discover/fresh ─────────────────────────────────────────────────────
public function fresh(Request $request)
{
$perPage = 24;
$results = $this->searchService->discoverFresh($perPage);
if ($this->paginatorIsEmpty($results)) {
$results = $this->fallbackFreshFromDatabase($perPage);
}
$this->hydrateDiscoverSearchResults($results);
return view('web.discover.index', [
'artworks' => $results,
'page_title' => 'Fresh Uploads',
'section' => 'fresh',
'description' => 'The latest artworks just uploaded to Skinbase.',
'icon' => 'fa-bolt',
]);
}
// ─── /discover/top-rated ─────────────────────────────────────────────────
public function topRated(Request $request)
{
$perPage = 24;
$page = max(1, (int) $request->query('page', 1));
$results = $this->searchService->discoverTopRated($perPage);
$results = $this->gridFiller->fill($results, 0, $page);
$this->hydrateDiscoverSearchResults($results);
return view('web.discover.index', [
'artworks' => $results,
'page_title' => 'Top Rated Artworks',
'section' => 'top-rated',
'description' => 'The most-loved artworks on Skinbase, ranked by community favourites.',
'icon' => 'fa-medal',
]);
}
// ─── /discover/most-downloaded ───────────────────────────────────────────
public function mostDownloaded(Request $request)
{
$perPage = 24;
$page = max(1, (int) $request->query('page', 1));
$results = $this->searchService->discoverMostDownloaded($perPage);
$results = $this->gridFiller->fill($results, 0, $page);
$this->hydrateDiscoverSearchResults($results);
return view('web.discover.index', [
'artworks' => $results,
'page_title' => 'Most Downloaded',
'section' => 'most-downloaded',
'description' => 'All-time most downloaded artworks on Skinbase.',
'icon' => 'fa-download',
]);
}
// ─── /discover/on-this-day ───────────────────────────────────────────────
public function onThisDay(Request $request)
{
$perPage = 24;
$today = now();
$artworks = Artwork::query()
->public()
->published()
->with([
'user:id,name',
'user.profile:user_id,avatar_hash',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
])
->whereRaw('MONTH(published_at) = ?', [$today->month])
->whereRaw('DAY(published_at) = ?', [$today->day])
->whereRaw('YEAR(published_at) < ?', [$today->year])
->orderMissingThumbnailsLast()
->orderByDesc('published_at')
->paginate($perPage)
->withQueryString();
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
return view('web.discover.index', [
'artworks' => $artworks,
'page_title' => 'On This Day',
'section' => 'on-this-day',
'description' => 'Artworks published on ' . $today->format('F j') . ' in previous years.',
'icon' => 'fa-calendar-day',
]);
}
// ─── /creators/rising ────────────────────────────────────────────────────
public function risingCreators(Request $request)
{
$perPage = 20;
// Creators with artworks published in the last 90 days, ordered by total recent views.
$hasStats = false;
try { $hasStats = Schema::hasTable('artwork_stats'); } catch (\Throwable) {}
if ($hasStats) {
$sub = Artwork::query()
->public()
->published()
->join('artwork_stats', 'artwork_stats.artwork_id', '=', 'artworks.id')
->where('artworks.published_at', '>=', now()->subDays(90))
->selectRaw('artworks.user_id, SUM(artwork_stats.views) as recent_views, MAX(artworks.published_at) as latest_published')
->groupBy('artworks.user_id');
} else {
$sub = Artwork::query()
->public()
->published()
->where('published_at', '>=', now()->subDays(90))
->selectRaw('user_id, COUNT(*) as recent_views, MAX(published_at) as latest_published')
->groupBy('user_id');
}
$creators = DB::table(DB::raw('(' . $sub->toSql() . ') as t'))
->mergeBindings($sub->getQuery())
->join('users as u', 'u.id', '=', 't.user_id')
->leftJoin('user_profiles as up', 'up.user_id', '=', 't.user_id')
->select('u.id as user_id', 'u.name as uname', 'u.username', 't.recent_views', 't.latest_published', 'up.avatar_hash')
->orderByDesc('t.recent_views')
->orderByDesc('t.latest_published')
->paginate($perPage)
->withQueryString();
$creators->getCollection()->transform(function ($row) {
return (object) [
'user_id' => $row->user_id,
'uname' => $row->uname,
'username' => $row->username,
'total' => (int) $row->recent_views,
'metric' => 'views',
'avatar_hash' => $row->avatar_hash ?? null,
];
});
return view('web.creators.rising', [
'creators' => $creators,
'page_title' => 'Rising Creators — Skinbase',
]);
}
// ─── /discover/for-you ───────────────────────────────────────────────────
/**
* Personalised "For You" feed page.
*
* Uses the newer personalized feed service so the web surface stays aligned
* with the API recommendation stack and discovery-event training loop.
*/
public function forYou(Request $request)
{
$user = $request->user();
$limit = max(1, min(50, (int) $request->query('limit', 40)));
$cursor = $request->query('cursor') ?: null;
$feedResult = $this->feedResolver->getFeed(
userId: (int) $user->id,
limit: $limit,
cursor: is_string($cursor) ? $cursor : null,
algoVersion: $request->filled('algo_version') ? (string) $request->query('algo_version') : null,
);
$artworks = collect($feedResult['data'] ?? [])->map(
fn (array $item) => $this->presentRecommendedArtwork($item)
);
$artworks = $this->reorderDiscoverItemsByThumbnailHealth($artworks)->values();
$meta = $feedResult['meta'] ?? [];
$nextCursor = $meta['next_cursor'] ?? null;
if ($request->ajax()) {
return response()->json([
'artworks' => $artworks->map(fn (object $artwork) => (array) $artwork)->all(),
'next_cursor' => $nextCursor,
'has_more' => ! empty($nextCursor),
'meta' => $meta,
]);
}
return view('web.discover.for-you', [
'artworks' => $artworks,
'page_title' => 'For You',
'section' => 'for-you',
'description' => 'Artworks picked for you based on your taste.',
'icon' => 'fa-wand-magic-sparkles',
'next_cursor' => $nextCursor,
'feed_meta' => $meta,
'cache_status' => $meta['cache_status'] ?? null,
]);
}
// ─── /discover/following ─────────────────────────────────────────────────
public function following(Request $request)
{
$user = $request->user();
$perPage = 24;
// Subquery: IDs of users this viewer follows
$followingIds = DB::table('user_followers')
->where('follower_id', $user->id)
->pluck('user_id');
if ($followingIds->isEmpty()) {
// Trending fallback: show popular artworks so the page isn't blank
try {
$fallbackResults = $this->searchService->discoverTrending(12);
$fallbackArtworks = $fallbackResults->getCollection()
->transform(fn ($a) => $this->presentArtwork($a));
} catch (\Throwable) {
$fallbackArtworks = collect();
}
// Suggested creators: most-followed users the viewer doesn't follow yet
$suggestedCreators = $this->userSuggestions->suggestFor($user, 6);
return view('web.discover.index', [
'artworks' => collect(),
'page_title' => 'Following Feed',
'section' => 'following',
'description' => 'Follow some creators to see their work here.',
'icon' => 'fa-user-group',
'empty' => true,
'fallback_trending' => $fallbackArtworks,
'fallback_creators' => $suggestedCreators,
'following_activity' => [],
'network_trending' => [],
'suggested_users' => $suggestedCreators,
]);
}
$page = (int) request()->get('page', 1);
$cacheKey = "discover.following.{$user->id}.p{$page}";
$artworks = Cache::remember($cacheKey, 60, function () use ($user, $followingIds, $perPage): \Illuminate\Pagination\LengthAwarePaginator {
return Artwork::query()
->public()
->published()
->with(['user:id,name,username', 'categories:id,name,slug,content_type_id,parent_id,sort_order'])
->whereIn('user_id', $followingIds)
->orderMissingThumbnailsLast()
->orderByDesc('published_at')
->paginate($perPage)
->withQueryString();
});
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
$networkActivity = $this->communityActivity->getFeed(
viewer: $user,
filter: 'following',
page: 1,
perPage: 8,
actorUserId: null,
);
return view('web.discover.index', [
'artworks' => $artworks,
'page_title' => 'Following Feed',
'section' => 'following',
'description' => 'The latest artworks from creators you follow.',
'icon' => 'fa-user-group',
'following_activity' => $networkActivity['data'] ?? [],
'network_trending' => $this->buildNetworkTrendingArtworks($followingIds->all(), 8),
'suggested_users' => $this->userSuggestions->suggestFor($user, 6),
]);
}
// ─── Helpers ─────────────────────────────────────────────────────────────
private function paginatorIsEmpty($paginator): bool
{
if (! is_object($paginator) || ! method_exists($paginator, 'getCollection')) {
return true;
}
$items = $paginator->getCollection();
return ! $items || $items->isEmpty();
}
private function paginatorHasNoRisingMomentum($paginator): bool
{
if (! is_object($paginator) || ! method_exists($paginator, 'getCollection')) {
return true;
}
$items = $paginator->getCollection();
if (! $items || $items->isEmpty()) {
return true;
}
return $items->every(function ($item): bool {
$heat = (float) ($item->heat_score ?? $item->stats?->heat_score ?? 0);
$velocity = (float) ($item->engagement_velocity ?? $item->stats?->engagement_velocity ?? 0);
return $heat <= 0.0 && $velocity <= 0.0;
});
}
private function fallbackFreshFromDatabase(int $perPage)
{
return Artwork::query()
->public()
->published()
->with([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
'categories.contentType:id,slug,name',
])
->orderMissingThumbnailsLast()
->orderByDesc('published_at')
->orderByDesc('id')
->paginate($perPage)
->withQueryString();
}
private function fallbackTrendingFromDatabase(int $perPage, int $windowDays)
{
$cutoff = now()->subDays($windowDays)->startOfDay();
return Artwork::query()
->public()
->published()
->with([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
'categories.contentType:id,slug,name',
])
->leftJoin('artwork_stats as discover_stats', 'discover_stats.artwork_id', '=', 'artworks.id')
->select('artworks.*')
->where('artworks.published_at', '>=', $cutoff)
->orderMissingThumbnailsLast()
->orderByDesc('discover_stats.ranking_score')
->orderByDesc('discover_stats.engagement_velocity')
->orderByDesc('discover_stats.views')
->orderByDesc('artworks.published_at')
->orderByDesc('artworks.id')
->paginate($perPage)
->withQueryString();
}
private function fallbackRisingFromDatabase(int $perPage, int $windowDays)
{
$cutoff = now()->subDays($windowDays)->startOfDay();
return Artwork::query()
->public()
->published()
->with([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
'categories.contentType:id,slug,name',
])
->leftJoin('artwork_stats as discover_stats', 'discover_stats.artwork_id', '=', 'artworks.id')
->select('artworks.*')
->selectRaw('COALESCE(discover_stats.heat_score, 0) as heat_score')
->selectRaw('COALESCE(discover_stats.engagement_velocity, 0) as engagement_velocity')
->where('artworks.published_at', '>=', $cutoff)
->orderMissingThumbnailsLast()
->orderByDesc('discover_stats.heat_score')
->orderByDesc('discover_stats.engagement_velocity')
->orderByDesc('artworks.published_at')
->orderByDesc('artworks.id')
->paginate($perPage)
->withQueryString();
}
private function fallbackRisingLowSignalFromDatabase(int $perPage, int $windowDays)
{
$cutoff = now()->subDays($windowDays)->startOfDay();
$recentActivity = $this->risingRecentActivitySubquery();
return Artwork::query()
->public()
->published()
->with([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
'categories.contentType:id,slug,name',
])
->leftJoin('artwork_stats as discover_stats', 'discover_stats.artwork_id', '=', 'artworks.id')
->leftJoinSub($recentActivity, 'recent_rising_activity', function ($join): void {
$join->on('recent_rising_activity.artwork_id', '=', 'artworks.id');
})
->select('artworks.*')
->selectRaw('COALESCE(discover_stats.heat_score, 0) as heat_score')
->selectRaw('COALESCE(discover_stats.engagement_velocity, 0) as engagement_velocity')
->selectRaw('COALESCE(recent_rising_activity.recent_signal_24h, 0) as recent_signal_24h')
->where('artworks.published_at', '>=', $cutoff)
->orderMissingThumbnailsLast()
->orderByDesc('recent_signal_24h')
->orderByDesc('artworks.published_at')
->orderByDesc('artworks.id')
->paginate($perPage)
->withQueryString();
}
private function risingRecentActivitySubquery()
{
$since = now()->startOfHour()->subHours(24);
return DB::table('artwork_metric_snapshots_hourly as rising_snapshots')
->selectRaw('rising_snapshots.artwork_id')
->selectRaw('(
COALESCE(MAX(rising_snapshots.views_count) - MIN(rising_snapshots.views_count), 0)
+ (COALESCE(MAX(rising_snapshots.downloads_count) - MIN(rising_snapshots.downloads_count), 0) * 3)
+ (COALESCE(MAX(rising_snapshots.favourites_count) - MIN(rising_snapshots.favourites_count), 0) * 4)
+ (COALESCE(MAX(rising_snapshots.comments_count) - MIN(rising_snapshots.comments_count), 0) * 5)
+ (COALESCE(MAX(rising_snapshots.shares_count) - MIN(rising_snapshots.shares_count), 0) * 6)
) as recent_signal_24h')
->where('rising_snapshots.bucket_hour', '>=', $since)
->groupBy('rising_snapshots.artwork_id');
}
private function hydrateDiscoverSearchResults($paginator): void
{
if (!is_object($paginator) || !method_exists($paginator, 'getCollection') || !method_exists($paginator, 'setCollection')) {
return;
}
$items = $paginator->getCollection();
if (!$items || $items->isEmpty()) {
return;
}
$ids = $items
->pluck('id')
->filter(fn ($id) => is_numeric($id) && (int) $id > 0)
->map(fn ($id) => (int) $id)
->values();
if ($ids->isEmpty()) {
return;
}
$byId = Artwork::query()
->whereIn('id', $ids)
->with([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
'group:id,name,slug,avatar_path',
'categories:id,name,slug,content_type_id,parent_id,sort_order',
])
->get()
->keyBy('id');
$paginator->setCollection(
$items->map(function ($item) use ($byId) {
$id = (int) ($item->id ?? 0);
$full = $id > 0 ? $byId->get($id) : null;
if ($full instanceof Artwork) {
return $this->presentArtwork($full);
}
return (object) [
'id' => $item->id ?? 0,
'name' => $item->title ?? $item->name ?? 'Untitled',
'category_name' => $item->category_name ?? $item->category ?? '',
'category_slug' => $item->category_slug ?? '',
'thumb_url' => $item->thumbnail_url ?? $item->thumb_url ?? $item->thumb ?? null,
'thumb_srcset' => $item->thumb_srcset ?? null,
'uname' => $item->author_name ?? $item->author ?? $item->uname ?? 'Skinbase',
'username' => (($item->published_as_type ?? null) === 'group') ? '' : ($item->username ?? ''),
'avatar_url' => \App\Support\AvatarUrl::forUser((int) ($item->user_id ?? $item->author_id ?? 0), null, 64),
'profile_url' => $item->profile_url ?? null,
'published_as_type' => $item->published_as_type ?? null,
'publisher' => $item->publisher ?? null,
'published_at' => $item->published_at ?? null,
'width' => isset($item->width) && $item->width ? (int) $item->width : null,
'height' => isset($item->height) && $item->height ? (int) $item->height : null,
];
})
);
}
private function presentArtwork(Artwork $artwork): object
{
$primaryCategory = $artwork->categories->sortBy('sort_order')->first();
$present = ThumbnailPresenter::present($artwork, 'md');
$group = $artwork->group;
$isGroupPublisher = $group !== null;
$avatarUrl = $isGroupPublisher
? $group->avatarUrl()
: \App\Support\AvatarUrl::forUser(
(int) ($artwork->user_id ?? 0),
$artwork->user?->profile?->avatar_hash ?? null,
64
);
$displayName = $isGroupPublisher ? ($group->name ?? 'Skinbase') : ($artwork->user?->name ?? 'Skinbase');
$username = $isGroupPublisher ? '' : ($artwork->user?->username ?? '');
$profileUrl = $isGroupPublisher ? $group->publicUrl() : ($username !== '' ? '/@' . $username : null);
return (object) $this->maturity->decoratePayload([
'id' => $artwork->id,
'name' => $artwork->title,
'content_type_name' => $primaryCategory?->contentType?->name ?? '',
'content_type_slug' => $primaryCategory?->contentType?->slug ?? '',
'category_name' => $primaryCategory->name ?? '',
'category_slug' => $primaryCategory->slug ?? '',
'gid_num' => $primaryCategory ? ((int) $primaryCategory->id % 5) * 5 : 0,
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'uname' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
'published_as_type' => $isGroupPublisher ? 'group' : 'user',
'publisher' => [
'type' => $isGroupPublisher ? 'group' : 'user',
'name' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
],
'published_at' => $artwork->published_at,
'width' => $artwork->width ?? null,
'height' => $artwork->height ?? null,
], $artwork, request()->user());
}
/**
* @param array<string, mixed> $item
*/
private function presentRecommendedArtwork(array $item): object
{
$width = isset($item['width']) && (int) $item['width'] > 0 ? (int) $item['width'] : null;
$height = isset($item['height']) && (int) $item['height'] > 0 ? (int) $item['height'] : null;
return (object) [
'id' => (int) ($item['id'] ?? 0),
'name' => (string) ($item['title'] ?? 'Untitled'),
'thumb_url' => $item['thumbnail_url'] ?? null,
'thumb_srcset' => $item['thumbnail_srcset'] ?? null,
'uname' => (string) ($item['author'] ?? 'Artist'),
'username' => (string) ($item['username'] ?? ''),
'avatar_url' => $item['avatar_url'] ?? null,
'published_at' => $item['published_at'] ?? null,
'slug' => (string) ($item['slug'] ?? ''),
'url' => $item['url'] ?? null,
'width' => $width,
'height' => $height,
'content_type_name' => (string) ($item['content_type_name'] ?? ''),
'content_type_slug' => (string) ($item['content_type_slug'] ?? ''),
'category_name' => (string) ($item['category_name'] ?? ''),
'category_slug' => (string) ($item['category_slug'] ?? ''),
'primary_tag' => $item['primary_tag'] ?? null,
'tags' => is_array($item['tags'] ?? null) ? $item['tags'] : [],
'recommendation_source' => (string) ($item['source'] ?? 'mixed'),
'recommendation_reason' => (string) ($item['reason'] ?? 'Picked for you'),
'recommendation_score' => isset($item['score']) ? round((float) $item['score'], 4) : null,
'recommendation_algo_version' => (string) ($item['algo_version'] ?? ''),
'hide_artwork_endpoint' => route('api.discovery.feedback.hide-artwork'),
'dislike_tag_endpoint' => route('api.discovery.feedback.dislike-tag'),
];
}
private function buildNetworkTrendingArtworks(array $followingIds, int $limit = 8): array
{
if ($followingIds === []) {
return [];
}
return Artwork::query()
->public()
->published()
->with(['user:id,name,username', 'user.profile:user_id,avatar_hash', 'stats:artwork_id,views,favorites,comments_count,heat_score'])
->whereIn('user_id', $followingIds)
->where('published_at', '>=', now()->subDays(30))
->leftJoin('artwork_stats as ast', 'ast.artwork_id', '=', 'artworks.id')
->orderMissingThumbnailsLast()
->orderByDesc(DB::raw('COALESCE(ast.heat_score, 0)'))
->orderByDesc(DB::raw('COALESCE(ast.favorites, 0)'))
->orderByDesc('artworks.published_at')
->limit(max(1, $limit))
->select('artworks.*')
->get()
->map(fn (Artwork $artwork) => [
'id' => (int) $artwork->id,
'title' => (string) $artwork->title,
'url' => route('art.show', ['id' => (int) $artwork->id, 'slug' => $artwork->slug]),
'thumb_url' => $artwork->thumb_url,
'published_at' => $artwork->published_at?->diffForHumans(),
'author' => [
'username' => $artwork->user?->username,
'name' => $artwork->user?->name,
'avatar_url' => $artwork->user?->profile?->avatar_url,
'profile_url' => $artwork->user?->username ? '/@' . strtolower((string) $artwork->user->username) : null,
],
'stats' => [
'favorites' => (int) ($artwork->stats?->favorites ?? 0),
'views' => (int) ($artwork->stats?->views ?? 0),
'comments' => (int) ($artwork->stats?->comments_count ?? 0),
],
])
->values()
->all();
}
/**
* @param Collection<int, object> $items
* @return Collection<int, object>
*/
private function reorderDiscoverItemsByThumbnailHealth(Collection $items): Collection
{
if ($items->isEmpty()) {
return $items;
}
$ids = $items
->pluck('id')
->filter(fn ($id) => is_numeric($id) && (int) $id > 0)
->map(fn ($id) => (int) $id)
->values();
if ($ids->isEmpty()) {
return $items;
}
$missingIds = Artwork::query()
->whereIn('id', $ids)
->where('has_missing_thumbnails', true)
->pluck('id')
->map(fn ($id) => (int) $id)
->flip();
if ($missingIds->isEmpty()) {
return $items;
}
$healthy = $items->reject(fn ($item) => $missingIds->has((int) ($item->id ?? 0)));
return $healthy
->concat($items->filter(fn ($item) => $missingIds->has((int) ($item->id ?? 0))))
->values();
}
}

View File

@@ -0,0 +1,112 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\ErrorSuggestionService;
use App\Services\NotFoundLogger;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
/**
* ErrorController
*
* Handles contextual 404 rendering.
* Invoked from bootstrap/app.php exception handler for web 404s.
*
* Pattern detection:
* /blog/* blog-not-found (latest posts)
* /tag/* tag-not-found (similar + trending tags)
* /@username creator-not-found (trending creators)
* /pages/* page-not-found
* /about|/help etc. page-not-found
* everything else generic 404 (trending artworks + tags)
*/
final class ErrorController extends Controller
{
public function __construct(
private readonly ErrorSuggestionService $suggestions,
private readonly NotFoundLogger $logger,
) {}
public function handleNotFound(Request $request): Response|JsonResponse
{
// For JSON / Inertia API requests return a minimal JSON 404.
if ($request->expectsJson() || $request->header('X-Inertia')) {
return response()->json(['message' => 'Not Found'], 404);
}
// Log every 404 hit for later analysis.
try {
$this->logger->log404($request);
} catch (\Throwable) {
// Never let the logger itself break the error page.
}
$path = ltrim($request->path(), '/');
// ── /blog/* ──────────────────────────────────────────────────────────
if (str_starts_with($path, 'blog/')) {
return response(view('errors.contextual.blog-not-found', [
'latestPosts' => $this->safeFetch(fn () => $this->suggestions->latestBlogPosts()),
]), 404);
}
// ── /tag/* ───────────────────────────────────────────────────────────
if (str_starts_with($path, 'tag/')) {
$slug = ltrim(substr($path, 4), '/');
return response(view('errors.contextual.tag-not-found', [
'requestedSlug' => $slug,
'similarTags' => $this->safeFetch(fn () => $this->suggestions->similarTags($slug)),
'trendingTags' => $this->safeFetch(fn () => $this->suggestions->trendingTags()),
]), 404);
}
// ── /@username or /creator/* ───────────────────────────────────────
if (str_starts_with($path, '@') || str_starts_with($path, 'creator/')) {
$username = str_starts_with($path, '@') ? substr($path, 1) : null;
return response(view('errors.contextual.creator-not-found', [
'requestedUsername' => $username,
'trendingCreators' => $this->safeFetch(fn () => $this->suggestions->trendingCreators()),
'recentCreators' => $this->safeFetch(fn () => $this->suggestions->recentlyJoinedCreators()),
]), 404);
}
// ── /{contentType}/{category}/{artwork-slug} — artwork not found ──────
if (preg_match('#^(wallpapers|skins|photography|other)/#', $path)) {
return response(view('errors.contextual.artwork-not-found', [
'trendingArtworks' => $this->safeFetch(fn () => $this->suggestions->trendingArtworks()),
]), 404);
}
// ── /pages/* or /about | /help | /contact | /legal/* ───────────────
if (
str_starts_with($path, 'pages/')
|| in_array($path, ['about', 'help', 'contact', 'faq', 'staff', 'privacy-policy', 'terms-of-service', 'rules-and-guidelines'])
|| str_starts_with($path, 'legal/')
) {
return response(view('errors.contextual.page-not-found'), 404);
}
// ── Generic 404 ───────────────────────────────────────────────────────
return response(view('errors.404', [
'trendingArtworks' => $this->safeFetch(fn () => $this->suggestions->trendingArtworks()),
'trendingTags' => $this->safeFetch(fn () => $this->suggestions->trendingTags()),
]), 404);
}
/**
* Silently catch any DB/cache error so the error page itself never crashes.
*/
private function safeFetch(callable $fn): mixed
{
try {
return $fn();
} catch (\Throwable) {
return collect();
}
}
}

View File

@@ -0,0 +1,351 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Models\ContentType;
use App\Services\ArtworkSearchService;
use App\Services\ContentTypes\ContentTypeSlugResolver;
use App\Services\EarlyGrowth\EarlyGrowth;
use App\Services\EarlyGrowth\GridFiller;
use App\Services\EarlyGrowth\SpotlightEngineInterface;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\ThumbnailPresenter;
use Illuminate\Http\Request;
use Illuminate\Pagination\AbstractCursorPaginator;
use Illuminate\Pagination\AbstractPaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
/**
* ExploreController
*
* Powers the /explore/* structured catalog pages (§3.2 of routing spec).
* Delegates to the same Meilisearch pipeline as BrowseGalleryController but
* uses canonical /explore/* URLs with the ExploreLayout blade template.
*/
final class ExploreController extends Controller
{
/** Meilisearch sort-field arrays per sort alias. */
private const SORT_MAP = [
'trending' => ['trending_score_24h:desc', 'trending_score_7d:desc', 'favorites_count:desc', 'created_at:desc'],
'fresh' => ['trending_score_7d:desc', 'favorites_count:desc', 'created_at:desc'],
'top-rated' => ['awards_received_count:desc', 'favorites_count:desc'],
'latest' => ['created_at:desc'],
// Legacy aliases kept for backward compatibility.
'new-hot' => ['trending_score_7d:desc', 'favorites_count:desc', 'created_at:desc'],
'best' => ['awards_received_count:desc', 'favorites_count:desc'],
];
private const SORT_TTL = [
'trending' => 300,
'fresh' => 120,
'top-rated'=> 600,
'latest' => 120,
'new-hot' => 120,
'best' => 600,
];
private const SORT_OPTIONS = [
['value' => 'trending', 'label' => '🔥 Trending'],
['value' => 'fresh', 'label' => '🚀 New & Hot'],
['value' => 'top-rated', 'label' => '⭐ Best'],
['value' => 'latest', 'label' => '🕐 Latest'],
];
private const SORT_ALIASES = [
'new-hot' => 'fresh',
'best' => 'top-rated',
];
public function __construct(
private readonly ArtworkSearchService $search,
private readonly GridFiller $gridFiller,
private readonly SpotlightEngineInterface $spotlight,
private readonly ContentTypeSlugResolver $contentTypeResolver,
private readonly ArtworkMaturityService $maturity,
) {}
// ── /explore (hub) ──────────────────────────────────────────────────
public function index(Request $request)
{
$sort = $this->resolveSort($request);
$perPage = $this->resolvePerPage($request);
$page = max(1, (int) $request->query('page', 1));
$ttl = self::SORT_TTL[$sort] ?? 300;
$artworks = Cache::remember("explore.all.{$sort}.{$page}", $ttl, fn () =>
$this->search->searchWithThumbnailPreference([
'filter' => 'is_public = true AND is_approved = true',
'sort' => self::SORT_MAP[$sort] ?? ['created_at:desc'],
], $perPage, false, $page)
);
// EGS: fill grid to minimum when uploads are sparse
$artworks = $this->gridFiller->fill($artworks, 0, $page);
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
// EGS §11: featured spotlight row on page 1 only
$spotlightItems = ($page === 1 && EarlyGrowth::spotlightEnabled())
? $this->spotlight->getSpotlight(6)->map(fn ($a) => $this->presentArtwork($a))
: collect();
$mainCategories = $this->mainCategories();
$seo = $this->paginationSeo($request, url('/explore'), $artworks);
return view('gallery.index', [
'gallery_type' => 'browse',
'mainCategories' => $mainCategories,
'subcategories' => $mainCategories,
'contentType' => null,
'category' => null,
'artworks' => $artworks,
'spotlight' => $spotlightItems,
'current_sort' => $sort,
'sort_options' => self::SORT_OPTIONS,
'hero_title' => 'Explore',
'hero_description' => 'Browse the full Skinbase catalog — wallpapers, skins, photography and more.',
'breadcrumbs' => collect([(object) ['name' => 'Explore', 'url' => '/explore']]),
'page_title' => 'Explore Artworks - Skinbase',
'page_meta_description' => 'Explore the full catalog of wallpapers, skins, photography and other artworks on Skinbase.',
'page_meta_keywords' => 'explore, wallpapers, skins, photography, artworks, skinbase',
'page_canonical' => $seo['canonical'],
'page_rel_prev' => $seo['prev'],
'page_rel_next' => $seo['next'],
'page_robots' => 'index,follow',
]);
}
// ── /explore/:type ──────────────────────────────────────────────────
public function byType(Request $request, string $type)
{
$resolution = $this->contentTypeResolver->resolve($type, allowVirtual: true);
if (! $resolution->found()) {
abort(404);
}
$isAll = $resolution->isVirtual && $resolution->virtualType === 'artworks';
if (! $isAll && $resolution->contentType === null) {
abort(404);
}
$resolvedTypeSlug = $isAll ? 'artworks' : strtolower((string) $resolution->contentType->slug);
// Canonical URLs for content types are /skins, /wallpapers, /photography, /other.
if (! $isAll) {
return redirect()->to($this->canonicalTypeUrl($request, $resolvedTypeSlug), 301);
}
$sort = $this->resolveSort($request);
$perPage = $this->resolvePerPage($request);
$page = max(1, (int) $request->query('page', 1));
$ttl = self::SORT_TTL[$sort] ?? 300;
$filter = 'is_public = true AND is_approved = true';
if (!$isAll) {
$filter .= ' AND content_type = "' . $type . '"';
}
$artworks = Cache::remember("explore.{$resolvedTypeSlug}.{$sort}.{$page}", $ttl, fn () =>
$this->search->searchWithThumbnailPreference([
'filter' => $filter,
'sort' => self::SORT_MAP[$sort] ?? ['created_at:desc'],
], $perPage, false, $page)
);
// EGS: fill grid to minimum when uploads are sparse
$artworks = $this->gridFiller->fill($artworks, 0, $page);
$artworks->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
// EGS §11: featured spotlight row on page 1 only
$spotlightItems = ($page === 1 && EarlyGrowth::spotlightEnabled())
? $this->spotlight->getSpotlight(6)->map(fn ($a) => $this->presentArtwork($a))
: collect();
$mainCategories = $this->mainCategories();
$contentType = null;
$subcategories = $mainCategories;
if (! $isAll) {
$contentType = $resolution->contentType;
$subcategories = $contentType
? $contentType->rootCategories()->orderBy('sort_order')->orderBy('name')->get()
: collect();
}
if ($isAll) {
$humanType = 'Artworks';
} else {
$humanType = $contentType?->name ?? ucfirst($resolvedTypeSlug);
}
$baseUrl = url('/explore/' . $resolvedTypeSlug);
$seo = $this->paginationSeo($request, $baseUrl, $artworks);
return view('gallery.index', [
'gallery_type' => $isAll ? 'browse' : 'content-type',
'mainCategories' => $mainCategories,
'subcategories' => $subcategories,
'contentType' => $contentType,
'category' => null,
'artworks' => $artworks,
'spotlight' => $spotlightItems,
'current_sort' => $sort,
'sort_options' => self::SORT_OPTIONS,
'hero_title' => $humanType,
'hero_description' => "Browse {$humanType} on Skinbase.",
'breadcrumbs' => collect([
(object) ['name' => 'Explore', 'url' => '/explore'],
(object) ['name' => $humanType, 'url' => "/explore/{$resolvedTypeSlug}"],
]),
'page_title' => "{$humanType} - Explore - Skinbase",
'page_meta_description' => "Discover the best {$humanType} artworks on Skinbase. Browse trending, new and top-rated.",
'page_meta_keywords' => strtolower($resolvedTypeSlug) . ', explore, skinbase, artworks, wallpapers, skins, photography',
'page_canonical' => $seo['canonical'],
'page_rel_prev' => $seo['prev'],
'page_rel_next' => $seo['next'],
'page_robots' => 'index,follow',
]);
}
// ── /explore/:type/:mode ────────────────────────────────────────────
public function byTypeMode(Request $request, string $type, string $mode)
{
$resolution = $this->contentTypeResolver->resolve($type, allowVirtual: true);
if (! $resolution->found()) {
abort(404);
}
if (! ($resolution->isVirtual && $resolution->virtualType === 'artworks')) {
$query = $request->query();
$query['sort'] = $this->normalizeSort((string) $mode);
return redirect()->to($this->canonicalTypeUrl($request, strtolower((string) $resolution->contentType?->slug), $query), 301);
}
// Rewrite the sort via the URL segment and delegate
$request->query->set('sort', $mode);
return $this->byType($request, $type);
}
// ── Helpers ──────────────────────────────────────────────────────────
private function mainCategories(): Collection
{
$categories = $this->contentTypeResolver
->publicContentTypes()
->map(fn ($ct) => (object) [
'name' => $ct->name,
'slug' => $ct->slug,
'url' => '/' . strtolower($ct->slug),
]);
return $categories->push((object) [
'name' => 'Members',
'slug' => 'members',
'url' => '/members',
]);
}
private function resolveSort(Request $request): string
{
$s = $this->normalizeSort((string) $request->query('sort', 'trending'));
return array_key_exists($s, self::SORT_MAP) ? $s : 'trending';
}
private function normalizeSort(string $sort): string
{
$sort = strtolower($sort);
return self::SORT_ALIASES[$sort] ?? $sort;
}
private function canonicalTypeUrl(Request $request, string $type, ?array $query = null): string
{
$query = $query ?? $request->query();
if (isset($query['sort'])) {
$query['sort'] = $this->normalizeSort((string) $query['sort']);
if ($query['sort'] === 'trending') {
unset($query['sort']);
}
}
return url('/' . $type) . ($query ? ('?' . http_build_query($query)) : '');
}
private function resolvePerPage(Request $request): int
{
$v = (int) ($request->query('per_page') ?: $request->query('limit') ?: 24);
return max(12, min($v, 80));
}
private function presentArtwork(Artwork $artwork): object
{
$primary = $artwork->categories->sortBy('sort_order')->first();
$present = ThumbnailPresenter::present($artwork, 'md');
$group = $artwork->group;
$isGroupPublisher = $group !== null;
$avatarUrl = $isGroupPublisher
? $group->avatarUrl()
: \App\Support\AvatarUrl::forUser(
(int) ($artwork->user_id ?? 0),
$artwork->user?->profile?->avatar_hash ?? null,
64
);
$displayName = $isGroupPublisher ? ($group->name ?? 'Skinbase') : ($artwork->user?->name ?? 'Skinbase');
$username = $isGroupPublisher ? '' : ($artwork->user?->username ?? '');
$profileUrl = $isGroupPublisher ? $group->publicUrl() : ($username !== '' ? '/@' . $username : null);
return (object) $this->maturity->decoratePayload([
'id' => $artwork->id,
'name' => $artwork->title,
'content_type_name' => $primary?->contentType?->name ?? '',
'content_type_slug' => $primary?->contentType?->slug ?? '',
'category_name' => $primary->name ?? '',
'category_slug' => $primary->slug ?? '',
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'uname' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
'published_as_type' => $isGroupPublisher ? 'group' : 'user',
'publisher' => [
'type' => $isGroupPublisher ? 'group' : 'user',
'name' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
],
'published_at' => $artwork->published_at,
'slug' => $artwork->slug ?? '',
'width' => $artwork->width ?? null,
'height' => $artwork->height ?? null,
], $artwork, request()->user());
}
private function paginationSeo(Request $request, string $base, mixed $paginator): array
{
$q = $request->query();
unset($q['grid']);
if (($q['page'] ?? null) !== null && (int) $q['page'] <= 1) {
unset($q['page']);
}
$canonical = $base . ($q ? '?' . http_build_query($q) : '');
$prev = null;
$next = null;
if ($paginator instanceof AbstractPaginator || $paginator instanceof AbstractCursorPaginator) {
$prev = $paginator->previousPageUrl();
$next = $paginator->nextPageUrl();
}
return compact('canonical', 'prev', 'next');
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\ArtworkService;
use App\Services\Maturity\ArtworkMaturityService;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Str;
class FeaturedArtworksController extends Controller
{
protected ArtworkService $artworks;
public function __construct(ArtworkService $artworks, private readonly ArtworkMaturityService $maturity)
{
$this->artworks = $artworks;
}
public function index(Request $request)
{
$perPage = 39;
$type = (int) ($request->query('type', 4));
$typeFilter = $type === 4 ? null : $type;
/** @var LengthAwarePaginator $artworks */
$artworks = $this->artworks->getFeaturedArtworks($typeFilter, $perPage);
$artworks->setCollection(
collect($this->maturity->filterPayloadItems($artworks->getCollection()->map(function (Artwork $artwork): array {
$primaryCategory = $artwork->categories->sortBy('sort_order')->first();
$categoryName = $primaryCategory->name ?? '';
$categorySlug = $primaryCategory->slug ?? '';
$gid = $primaryCategory ? ((int) $primaryCategory->id % 5) * 5 : 0;
$present = \App\Services\ThumbnailPresenter::present($artwork, 'md');
$username = $artwork->user->username ?? $artwork->user->name ?? 'Skinbase';
return $this->maturity->decoratePayload([
'id' => $artwork->id,
'name' => $artwork->title,
'slug' => $artwork->slug,
'url' => url('/art/' . $artwork->id . '/' . Str::slug($artwork->title ?? 'artwork')),
'content_type_name' => $primaryCategory?->contentType?->name ?? '',
'content_type_slug' => $primaryCategory?->contentType?->slug ?? '',
'category_name' => $categoryName,
'category_slug' => $categorySlug,
'gid_num' => $gid,
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'width' => $artwork->width,
'height' => $artwork->height,
'uname' => $artwork->user->name ?? 'Skinbase',
'username' => $username,
], $artwork, $request->user());
})->values()->all(), $request->user()))
->map(static fn (array $item): object => (object) $item)
->values()
);
$artworkTypes = [
1 => 'Bronze Awards',
2 => 'Silver Awards',
3 => 'Gold Awards',
4 => 'Featured Artworks',
];
$pageTitle = $artworkTypes[$type] ?? 'Featured Artworks';
return view('web.featured-artworks', [
'artworks' => $artworks,
'type' => $type,
'artworkTypes' => $artworkTypes,
'page_title' => $pageTitle,
]);
}
}

View File

@@ -0,0 +1,117 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\View\View;
/**
* FooterController serves static footer pages.
*
* /faq faq()
* /rules-and-guidelines rules()
* /privacy-policy privacyPolicy()
* /terms-of-service termsOfService()
*/
final class FooterController extends Controller
{
public function faq(): View
{
return view('web.faq', [
'page_title' => 'FAQ — Skinbase',
'page_meta_description' => 'Frequently Asked Questions about Skinbase — the community for skins, wallpapers, and photography.',
'page_canonical' => url('/faq'),
'faq_schema' => [[
'@context' => 'https://schema.org',
'@type' => 'FAQPage',
'mainEntity' => [
[
'@type' => 'Question',
'name' => 'What is Skinbase?',
'acceptedAnswer' => [
'@type' => 'Answer',
'text' => 'Skinbase is a community gallery for desktop customisation including skins, themes, wallpapers, icons, and more.',
],
],
[
'@type' => 'Question',
'name' => 'Is Skinbase free to use?',
'acceptedAnswer' => [
'@type' => 'Answer',
'text' => 'Yes. Browsing and downloading are free, and registering is also free.',
],
],
[
'@type' => 'Question',
'name' => 'Who runs Skinbase?',
'acceptedAnswer' => [
'@type' => 'Answer',
'text' => 'Skinbase is maintained by a small volunteer staff team.',
],
],
],
]],
'hero_title' => 'Frequently Asked Questions',
'hero_description' => 'Answers to the most common questions from our members. Last updated March 1, 2026.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'FAQ', 'url' => '/faq'],
]),
'center_content' => true,
'center_max' => '3xl',
]);
}
public function rules(): View
{
return view('web.rules', [
'page_title' => 'Rules & Guidelines — Skinbase',
'page_meta_description' => 'Read the Skinbase community rules and content guidelines before submitting your work.',
'page_canonical' => url('/rules-and-guidelines'),
'hero_title' => 'Rules & Guidelines',
'hero_description' => 'Please review these guidelines before uploading or participating. Last updated March 1, 2026.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Rules & Guidelines', 'url' => '/rules-and-guidelines'],
]),
'center_content' => true,
'center_max' => '3xl',
]);
}
public function termsOfService(): View
{
return view('web.terms-of-service', [
'page_title' => 'Terms of Service — Skinbase',
'page_meta_description' => 'Read the Skinbase Terms of Service — the agreement that governs your use of the platform.',
'page_canonical' => url('/terms-of-service'),
'hero_title' => 'Terms of Service',
'hero_description' => 'The agreement between you and Skinbase that governs your use of the platform. Last updated March 1, 2026.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Terms of Service', 'url' => '/terms-of-service'],
]),
'center_content' => true,
'center_max' => '3xl',
]);
}
public function privacyPolicy(): View
{
return view('web.privacy-policy', [
'page_title' => 'Privacy Policy — Skinbase',
'page_meta_description' => 'Read the Skinbase privacy policy to understand how we collect and use your data.',
'page_canonical' => url('/privacy-policy'),
'hero_title' => 'Privacy Policy',
'hero_description' => 'How Skinbase collects, uses, and protects your information. Last updated March 1, 2026.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Privacy Policy', 'url' => '/privacy-policy'],
]),
'center_content' => true,
'center_max' => '3xl',
]);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\User;
use App\Support\UsernamePolicy;
class GalleryController extends Controller
{
public function show(Request $request, $userId, $username = null)
{
$user = User::find((int) $userId);
if (! $user) {
abort(404);
}
$usernameSlug = UsernamePolicy::normalize((string) ($user->username ?? $user->name ?? ''));
if ($usernameSlug === '') {
abort(404);
}
return redirect()->route('profile.gallery', ['username' => $usernameSlug], 301);
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class GroupFaqPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.groups.faq');
$seo = app(SeoFactory::class)
->collectionPage(
'Groups FAQ — Skinbase',
'Fast answers to the most common Groups questions on Skinbase Nova, including roles, permissions, publishing, contributor credit, invites, workflows, and troubleshooting.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Group/GroupFaqPage', [
'title' => 'Groups FAQ',
'description' => 'Quick answers about Groups, roles, permissions, publishing, contributor credit, invites, workflows, and troubleshooting on Skinbase Nova.',
'seo' => $seo,
'links' => [
'groups_directory' => route('groups.index'),
'create_group' => route('studio.groups.create'),
'group_studio' => route('studio.groups.index'),
'full_documentation' => route('help.groups'),
'quickstart' => route('help.groups.quickstart'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
'help_home' => route('help'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class GroupHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.groups');
$seo = app(SeoFactory::class)
->collectionPage(
'Groups Guide, Help, and Best Practices — Skinbase',
'Learn how Groups work on Skinbase Nova, how shared publishing preserves contributor credit, and how to manage roles, releases, reviews, projects, and team workflows with confidence.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Group/GroupHelpPage', [
'title' => 'Groups Help & Guide',
'description' => 'Everything creators need to understand Groups, publish collaboratively, preserve contributor credit, and build a healthy shared identity on Skinbase Nova.',
'seo' => $seo,
'links' => [
'groups_directory' => route('groups.index'),
'create_group' => route('studio.groups.create'),
'group_studio' => route('studio.groups.index'),
'quickstart' => route('help.groups.quickstart'),
'faq' => route('help.groups.faq'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
'help_home' => route('help'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class GroupQuickstartPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.groups.quickstart');
$seo = app(SeoFactory::class)
->collectionPage(
'Groups Quickstart — Skinbase',
'A fast, creator-friendly Groups quickstart for Skinbase Nova. Learn when to use a Group, create one, invite members, and publish your first Group artwork with correct contributor credit.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Group/GroupQuickstartPage', [
'title' => 'Groups Quickstart',
'description' => 'The fastest way to understand Groups, create one, invite members, and publish your first collaborative artwork with correct contributor credit.',
'seo' => $seo,
'links' => [
'groups_directory' => route('groups.index'),
'create_group' => route('studio.groups.create'),
'group_studio' => route('studio.groups.index'),
'full_documentation' => route('help.groups'),
'faq' => route('help.groups.faq'),
'help_home' => route('help'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class HelpCenterPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help');
$seo = app(SeoFactory::class)
->collectionPage(
'Help Center — Skinbase',
'Find help, guides, quickstarts, FAQs, and troubleshooting for Skinbase Nova, including Groups, Studio, Upload, Cards, Profile, and account access.',
$canonical,
)
->toArray();
$seo['og_type'] = 'website';
return Inertia::render('Help/HelpCenterPage', [
'title' => 'Help Center',
'description' => 'Find guides, quickstarts, FAQs, and troubleshooting for Skinbase Nova in one structured help hub.',
'seo' => $seo,
'links' => [
'studio_help' => route('help.studio'),
'upload_help' => route('help.upload'),
'groups_documentation' => route('help.groups'),
'groups_quickstart' => route('help.groups.quickstart'),
'groups_faq' => route('help.groups.faq'),
'groups_directory' => route('groups.index'),
'group_studio' => route('studio.groups.index'),
'create_group' => route('studio.groups.create'),
'open_studio' => route('studio.index'),
'studio_home' => route('studio.index'),
'studio_content' => route('studio.content'),
'studio_artworks' => route('studio.artworks'),
'studio_cards' => route('studio.cards.index'),
'studio_drafts' => route('studio.drafts'),
'cards_create' => route('studio.cards.create'),
'upload' => route('upload'),
'cards_index' => route('cards.index'),
'help_cards' => route('help.cards'),
'help_profile' => route('help.profile'),
'help_auth' => route('help.auth'),
'help_account' => route('help.account'),
'help_troubleshooting' => route('help.troubleshooting'),
'profile_settings' => route('dashboard.profile'),
'login' => route('login'),
'register' => route('register'),
'password_request' => route('password.request'),
'help_upload' => route('help', ['q' => 'upload']),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\HomepageService;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
final class HomeController extends Controller
{
public function __construct(private readonly HomepageService $homepage) {}
public function index(Request $request): \Illuminate\View\View
{
$user = $request->user();
$sections = $user
? $this->homepage->allForUser($user)
: array_merge($this->homepage->all(), ['is_logged_in' => false]);
$hero = $sections['hero'];
$meta = [
'title' => 'Skinbase Digital Art & Wallpapers',
'description' => 'Discover stunning digital art, wallpapers, and skins from a global community of creators. Browse trending works, fresh uploads, and beloved classics.',
'keywords' => 'wallpapers, digital art, skins, photography, community, wallpaper downloads',
'og_image' => $hero['thumb_lg'] ?? $hero['thumb'] ?? null,
'canonical' => url('/'),
];
return view('web.home', [
'seo' => app(SeoFactory::class)->homepage($meta)->toArray(),
'useUnifiedSeo' => true,
'meta' => $meta,
'props' => $sections,
]);
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Leaderboard;
use App\Services\LeaderboardService;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class LeaderboardPageController extends Controller
{
public function __invoke(Request $request, LeaderboardService $leaderboards): Response
{
$period = $leaderboards->normalizePeriod((string) $request->query('period', 'weekly'));
$type = match ((string) $request->query('type', 'creators')) {
'artworks', Leaderboard::TYPE_ARTWORK => Leaderboard::TYPE_ARTWORK,
'groups', Leaderboard::TYPE_GROUP => Leaderboard::TYPE_GROUP,
'stories', Leaderboard::TYPE_STORY => Leaderboard::TYPE_STORY,
default => Leaderboard::TYPE_CREATOR,
};
$title = match ($type) {
Leaderboard::TYPE_GROUP => 'Top Groups Leaderboard — Skinbase',
Leaderboard::TYPE_STORY => 'Top Stories Leaderboard — Skinbase',
Leaderboard::TYPE_ARTWORK => 'Top Artworks Leaderboard — Skinbase',
default => 'Top Creators & Artworks Leaderboard — Skinbase',
};
$description = match ($type) {
Leaderboard::TYPE_GROUP => 'Track the leading groups across Skinbase by daily, weekly, monthly, and all-time performance.',
Leaderboard::TYPE_STORY => 'Track the leading stories across Skinbase by daily, weekly, monthly, and all-time performance.',
Leaderboard::TYPE_ARTWORK => 'Track the leading artworks across Skinbase by daily, weekly, monthly, and all-time performance.',
default => 'Track the leading creators, groups, artworks, and stories across Skinbase by daily, weekly, monthly, and all-time performance.',
};
return Inertia::render('Leaderboard/LeaderboardPage', [
'initialType' => $type,
'initialPeriod' => $period,
'initialData' => $leaderboards->getLeaderboard($type, $period),
'seo' => app(SeoFactory::class)->leaderboardPage(
$title,
$description,
route('leaderboard')
)->toArray(),
]);
}
}

View File

@@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Page;
use Illuminate\View\View;
/**
* PageController DB-driven static pages (/pages/:slug).
*
* Also handles root-level marketing pages (/about, /help, /contact)
* and legal pages (/legal/terms, /legal/privacy, /legal/cookies).
*/
final class PageController extends Controller
{
public function show(string $slug): View
{
$page = Page::published()->where('slug', $slug)->firstOrFail();
return view('web.pages.show', [
'page' => $page,
'page_title' => ($page->meta_title ?: $page->title) . ' — Skinbase',
'page_meta_description' => $page->meta_description ?: '',
'page_canonical' => $page->canonical_url,
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => $page->title, 'url' => $page->url],
]),
]);
}
/**
* Serve root-level marketing slugs (/about, /help, /contact).
* Falls back to 404 if no matching page exists.
*/
public function marketing(string $slug): View
{
$page = Page::published()->where('slug', $slug)->firstOrFail();
return view('web.pages.show', [
'page' => $page,
'page_title' => ($page->meta_title ?: $page->title) . ' — Skinbase',
'page_meta_description' => $page->meta_description ?: '',
'page_canonical' => url('/' . $slug),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => $page->title, 'url' => '/' . $slug],
]),
]);
}
/**
* Legal pages (/legal/terms, /legal/privacy, /legal/cookies).
* Looks for page with slug "legal-{section}".
*/
public function legal(string $section): View
{
$page = Page::published()->where('slug', 'legal-' . $section)->firstOrFail();
return view('web.pages.show', [
'page' => $page,
'page_title' => ($page->meta_title ?: $page->title) . ' — Skinbase',
'page_meta_description' => $page->meta_description ?: '',
'page_canonical' => url('/legal/' . $section),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Legal', 'url' => '#'],
(object) ['name' => $page->title, 'url' => '/legal/' . $section],
]),
]);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Web\Posts;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class FollowingFeedController extends Controller
{
/**
* GET /feed/following
* Renders the Following Feed Inertia page.
* Actual data is loaded client-side via GET /api/posts/following
*/
public function index(Request $request): Response
{
return Inertia::render('Feed/FollowingFeed', [
'auth' => [
'user' => $request->user() ? [
'id' => $request->user()->id,
'username' => $request->user()->username,
'name' => $request->user()->name,
'avatar' => $request->user()->profile?->avatar_url ?? null,
] : null,
],
]);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Web\Posts;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class HashtagFeedController extends Controller
{
/** GET /tags/{tag} */
public function index(Request $request, string $tag): Response
{
return Inertia::render('Feed/HashtagFeed', [
'auth' => $request->user() ? [
'user' => [
'id' => $request->user()->id,
'username' => $request->user()->username,
'name' => $request->user()->name,
'avatar' => $request->user()->profile?->avatar_url ?? null,
],
] : null,
'tag' => strtolower($tag),
]);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\Web\Posts;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class SavedFeedController extends Controller
{
/** GET /feed/saved */
public function index(Request $request): Response
{
return Inertia::render('Feed/SavedFeed', [
'auth' => [
'user' => [
'id' => $request->user()->id,
'username' => $request->user()->username,
'name' => $request->user()->name,
'avatar' => $request->user()->profile?->avatar_url ?? null,
],
],
]);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers\Web\Posts;
use App\Http\Controllers\Controller;
use App\Services\Posts\PostHashtagService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Inertia\Inertia;
use Inertia\Response;
class SearchFeedController extends Controller
{
public function __construct(private PostHashtagService $hashtagService) {}
/** GET /feed/search */
public function index(Request $request): Response
{
$trendingHashtags = Cache::remember(
'trending_hashtags',
300,
fn () => $this->hashtagService->trending(10, 24)
);
return Inertia::render('Feed/SearchFeed', [
'auth' => $request->user() ? [
'user' => [
'id' => $request->user()->id,
'username' => $request->user()->username,
'name' => $request->user()->name,
'avatar' => $request->user()->profile?->avatar_url ?? null,
],
] : null,
'initialQuery' => $request->query('q', ''),
'trendingHashtags' => $trendingHashtags,
]);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers\Web\Posts;
use App\Http\Controllers\Controller;
use App\Services\Posts\PostHashtagService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Inertia\Inertia;
use Inertia\Response;
class TrendingFeedController extends Controller
{
public function __construct(private PostHashtagService $hashtagService) {}
/** GET /feed/trending */
public function index(Request $request): Response
{
$trendingHashtags = Cache::remember('trending_hashtags', 300, fn () => $this->hashtagService->trending(10, 24));
return Inertia::render('Feed/TrendingFeed', [
'auth' => $request->user() ? [
'user' => [
'id' => $request->user()->id,
'username' => $request->user()->username,
'name' => $request->user()->name,
'avatar' => $request->user()->profile?->avatar_url ?? null,
],
] : null,
'trendingHashtags' => $trendingHashtags,
]);
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class ProfileHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.profile');
$seo = app(SeoFactory::class)
->collectionPage(
'Profile Help — Skinbase',
'Learn how profiles work on Skinbase Nova, how they differ from Groups, and how to build a stronger personal identity with better setup, presentation, and creator-facing profile habits.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/ProfileHelpPage', [
'title' => 'Profile Help',
'description' => 'Understand your Skinbase profile as your personal public identity, with practical guidance for setup, presentation, profile content, and creator-friendly best practices.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'groups_help' => route('help.groups'),
'studio_help' => route('help.studio'),
'upload_help' => route('help.upload'),
'cards_help' => route('help.cards'),
'profile_settings' => route('dashboard.profile'),
'open_studio' => route('studio.index'),
'help_auth' => route('help.auth'),
'login' => route('login'),
'register' => route('register'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,187 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\ContentTypes\ContentTypeSlugResolver;
use Illuminate\Http\Response;
use Illuminate\View\View;
/**
* RssFeedController
*
* GET /rss-feeds info page listing all available feeds
* GET /rss/latest-uploads.xml all published artworks (legacy)
* GET /rss/latest-skins.xml skins only (legacy)
* GET /rss/latest-wallpapers.xml wallpapers only (legacy)
* GET /rss/latest-photos.xml photography only (legacy)
*
* Nova feeds live in App\Http\Controllers\RSS\*.
*/
final class RssFeedController extends Controller
{
/** Number of items per legacy feed. */
private const FEED_LIMIT = 25;
/** Flat feed list kept for backward-compatibility (old view logic). */
public const FEEDS = [
'uploads' => ['title' => 'Latest Uploads', 'url' => '/rss/latest-uploads.xml'],
'skins' => ['title' => 'Latest Skins', 'url' => '/rss/latest-skins.xml'],
'wallpapers' => ['title' => 'Latest Wallpapers', 'url' => '/rss/latest-wallpapers.xml'],
'photos' => ['title' => 'Latest Photos', 'url' => '/rss/latest-photos.xml'],
];
public function __construct(private readonly ContentTypeSlugResolver $contentTypeResolver)
{
}
/** Info page at /rss-feeds */
public function index(): View
{
return view('web.rss-feeds', [
'page_title' => 'RSS Feeds — Skinbase',
'page_meta_description' => 'Subscribe to Skinbase RSS feeds to stay up to date with the latest uploads, skins, wallpapers, and photos.',
'page_canonical' => url('/rss-feeds'),
'hero_title' => 'RSS Feeds',
'hero_description' => 'Subscribe to stay up to date with the latest content on Skinbase.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'RSS Feeds', 'url' => '/rss-feeds'],
]),
'feeds' => self::FEEDS,
'feed_groups' => $this->feedGroups(),
'center_content' => true,
'center_max' => '3xl',
]);
}
/** /rss/latest-uploads.xml — all content types */
public function latestUploads(): Response
{
$artworks = Artwork::published()
->with(['user'])
->latest('published_at')
->limit(self::FEED_LIMIT)
->get();
return $this->buildFeed('Latest Uploads', url('/rss/latest-uploads.xml'), $artworks);
}
/** /rss/latest-skins.xml */
public function latestSkins(): Response
{
return $this->feedByContentType('skins', 'Latest Skins', '/rss/latest-skins.xml');
}
/** /rss/latest-wallpapers.xml */
public function latestWallpapers(): Response
{
return $this->feedByContentType('wallpapers', 'Latest Wallpapers', '/rss/latest-wallpapers.xml');
}
/** /rss/latest-photos.xml */
public function latestPhotos(): Response
{
return $this->feedByContentType('photography', 'Latest Photos', '/rss/latest-photos.xml');
}
// -------------------------------------------------------------------------
private function feedByContentType(string $slug, string $title, string $feedPath): Response
{
$contentType = $this->contentTypeResolver->resolve($slug)->contentType;
$query = Artwork::published()->with(['user'])->latest('published_at')->limit(self::FEED_LIMIT);
if ($contentType) {
$query->whereHas('categories', fn ($q) => $q->where('content_type_id', $contentType->id));
}
return $this->buildFeed($title, url($feedPath), $query->get());
}
private function buildFeed(string $channelTitle, string $feedUrl, $artworks): Response
{
$content = view('rss.feed', [
'channelTitle' => $channelTitle . ' — Skinbase',
'channelDescription' => 'The latest ' . strtolower($channelTitle) . ' from Skinbase.org',
'channelLink' => url('/'),
'feedUrl' => $feedUrl,
'artworks' => $artworks,
'buildDate' => now()->toRfc2822String(),
])->render();
return response($content, 200, [
'Content-Type' => 'application/rss+xml; charset=utf-8',
]);
}
private function feedGroups(): array
{
$exploreFeeds = [[
'title' => 'All Artworks',
'url' => '/rss/explore/artworks',
'description' => 'Latest artworks of all types.',
]];
foreach ($this->contentTypeResolver->publicContentTypes() as $contentType) {
$name = (string) $contentType->name;
$slug = (string) $contentType->slug;
$exploreFeeds[] = [
'title' => $name,
'url' => '/rss/explore/' . $slug,
'description' => 'Latest ' . strtolower($name) . '.',
];
}
if ($this->contentTypeResolver->publicContentTypes()->isNotEmpty()) {
$firstType = $this->contentTypeResolver->publicContentTypes()->first();
$exploreFeeds[] = [
'title' => 'Trending ' . $firstType->name,
'url' => '/rss/explore/' . $firstType->slug . '/trending',
'description' => 'Trending ' . strtolower((string) $firstType->name) . ' this week.',
];
}
return [
'global' => [
'label' => 'Global',
'feeds' => [
['title' => 'Latest Artworks', 'url' => '/rss', 'description' => 'All new artworks across the platform.'],
],
],
'discover' => [
'label' => 'Discover',
'feeds' => [
['title' => 'Fresh Uploads', 'url' => '/rss/discover/fresh', 'description' => 'The newest artworks just published.'],
['title' => 'Trending', 'url' => '/rss/discover/trending', 'description' => 'Most-viewed artworks over the past 7 days.'],
['title' => 'Rising', 'url' => '/rss/discover/rising', 'description' => 'Artworks gaining momentum right now.'],
],
],
'explore' => [
'label' => 'Explore',
'feeds' => $exploreFeeds,
],
'blog' => [
'label' => 'Blog',
'feeds' => [
['title' => 'Blog Posts', 'url' => '/rss/blog', 'description' => 'Latest posts from the Skinbase blog.'],
],
],
'legacy' => [
'label' => 'Legacy Feeds',
'feeds' => [
['title' => 'Latest Uploads (XML)', 'url' => '/rss/latest-uploads.xml', 'description' => 'Legacy XML feed.'],
['title' => 'Latest Skins (XML)', 'url' => '/rss/latest-skins.xml', 'description' => 'Legacy XML feed.'],
['title' => 'Latest Wallpapers (XML)', 'url' => '/rss/latest-wallpapers.xml', 'description' => 'Legacy XML feed.'],
['title' => 'Latest Photos (XML)', 'url' => '/rss/latest-photos.xml', 'description' => 'Legacy XML feed.'],
],
],
];
}
}

View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\ArtworkSearchService;
use App\Services\GroupDiscoveryService;
use Illuminate\Http\Request;
use Illuminate\View\View;
use cPad\Plugins\News\Models\NewsArticle;
final class SearchController extends Controller
{
public function __construct(
private readonly ArtworkSearchService $search,
private readonly GroupDiscoveryService $groups,
) {}
public function index(Request $request): View
{
$q = trim((string) $request->query('q', ''));
$sort = $request->query('sort', 'latest');
$sortMap = [
'popular' => 'views:desc',
'likes' => 'likes:desc',
'latest' => 'created_at:desc',
'downloads' => 'downloads:desc',
];
$artworks = $q !== ''
? $this->search->search($q, [
'sort' => ($sortMap[$sort] ?? 'created_at:desc'),
])
: $this->search->popular(24);
$groups = $q !== ''
? $this->groups->searchCards($q, $request->user(), 6)
: $this->groups->surfaceCards($request->user(), 'featured', 4);
$news = $q !== ''
? NewsArticle::query()
->with(['author:id,username,name', 'category:id,name,slug'])
->published()
->where(function ($builder) use ($q): void {
$builder->where('title', 'like', '%' . $q . '%')
->orWhere('excerpt', 'like', '%' . $q . '%')
->orWhere('content', 'like', '%' . $q . '%')
->orWhere('meta_title', 'like', '%' . $q . '%');
})
->editorialOrder()
->limit(4)
->get()
: collect();
return view('search.index', [
'q' => $q,
'sort' => $sort,
'groups' => $groups,
'artworks' => $artworks,
'news' => $news,
'page_title' => $q !== '' ? 'Search: ' . $q . ' — Skinbase' : 'Search — Skinbase',
'page_meta_description' => 'Search Skinbase for artworks, creators, groups, photography, wallpapers and skins.',
'page_robots' => 'noindex,follow',
]);
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\ContentType;
use Illuminate\Support\Facades\DB;
class SectionsController extends Controller
{
public function index()
{
// Load all content types with full category tree (roots + children)
$contentTypes = ContentType::with([
'rootCategories' => function ($q) {
$q->active()
->withCount(['artworks as artwork_count'])
->orderBy('sort_order')
->orderBy('name');
},
'rootCategories.children' => function ($q) {
$q->active()
->withCount(['artworks as artwork_count'])
->orderBy('sort_order')
->orderBy('name');
},
])->ordered()->get();
// Total artwork counts per content type via a single aggregation query
$artworkCountsByType = DB::table('artworks')
->join('artwork_category', 'artworks.id', '=', 'artwork_category.artwork_id')
->join('categories', 'artwork_category.category_id', '=', 'categories.id')
->where('artworks.is_approved', true)
->where('artworks.is_public', true)
->whereNull('artworks.deleted_at')
->select('categories.content_type_id', DB::raw('COUNT(DISTINCT artworks.id) as total'))
->groupBy('categories.content_type_id')
->pluck('total', 'content_type_id');
return view('web.sections', [
'contentTypes' => $contentTypes,
'artworkCountsByType' => $artworkCountsByType,
'page_title' => 'Browse Sections',
'page_meta_description' => 'Browse all artwork sections on Skinbase — Photography, Wallpapers, Skins and more.',
]);
}
}

View File

@@ -0,0 +1,340 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\Recommendations\HybridSimilarArtworksService;
use App\Services\ThumbnailPresenter;
use App\Services\Vision\VectorService;
use App\Support\AvatarUrl;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use RuntimeException;
/**
* GET /art/{id}/similar
*
* Renders a full gallery page of artworks similar to the given source artwork.
*
* Priority:
* 1. Qdrant visual similarity (VectorService / vision gateway)
* 2. HybridSimilarArtworksService (precomputed tag, behavior, hybrid)
* 3. Meilisearch tag-overlap + category fallback
*/
final class SimilarArtworksPageController extends Controller
{
private const PER_PAGE = 24;
/** How many candidates to request from Qdrant (> PER_PAGE to allow pagination) */
private const QDRANT_LIMIT = 120;
public function __construct(
private readonly VectorService $vectors,
private readonly ArtworkMaturityService $maturity,
private readonly HybridSimilarArtworksService $hybridService,
) {}
public function __invoke(Request $request, int $id)
{
// ── Load source artwork ────────────────────────────────────────────────
$source = Artwork::public()
->published()
->with([
'tags:id,slug',
'categories:id,slug,name',
'categories.contentType:id,name,slug',
'user:id,name,username',
'user.profile:user_id,avatar_hash',
])
->findOrFail($id);
$baseUrl = url("/art/{$id}/similar");
// ── Normalise source artwork for the view ──────────────────────────────
$primaryCat = $source->categories->sortBy('sort_order')->first();
$sourceMd = ThumbnailPresenter::present($source, 'md');
$sourceLg = ThumbnailPresenter::present($source, 'lg');
$sourceTitle = html_entity_decode((string) ($source->title ?? 'Artwork'), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$sourceUrl = route('art.show', ['id' => $source->id, 'slug' => $source->slug]);
$sourceCard = (object) [
'id' => $source->id,
'title' => $sourceTitle,
'url' => $sourceUrl,
'thumb_md' => $sourceMd['url'] ?? null,
'thumb_lg' => $sourceLg['url'] ?? null,
'thumb_srcset' => $sourceMd['srcset'] ?? $sourceMd['url'] ?? null,
'author_name' => $source->user?->name ?? 'Artist',
'author_username' => $source->user?->username ?? '',
'author_profile_url'=> $source->user?->username ? '/@' . $source->user->username : null,
'author_avatar' => AvatarUrl::forUser(
(int) ($source->user_id ?? 0),
$source->user?->profile?->avatar_hash ?? null,
80
),
'category_name' => $primaryCat?->name ?? '',
'category_slug' => $primaryCat?->slug ?? '',
'content_type_name' => $primaryCat?->contentType?->name ?? '',
'content_type_slug' => $primaryCat?->contentType?->slug ?? '',
'browse_url' => $primaryCat?->contentType?->slug ? url('/' . $primaryCat->contentType->slug) : url('/explore'),
'tag_slugs' => $source->tags->pluck('slug')->take(5)->all(),
'width' => $source->width ?? null,
'height' => $source->height ?? null,
];
return view('gallery.similar', [
'sourceArtwork' => $sourceCard,
'gallery_type' => 'similar',
'gallery_nav_section' => 'artworks',
'mainCategories' => collect(),
'subcategories' => collect(),
'contentType' => null,
'category' => null,
'spotlight' => collect(),
'current_sort' => 'trending',
'sort_options' => [],
'page_title' => 'Similar to "' . $sourceTitle . '" — Skinbase',
'page_meta_description' => 'Discover artworks similar to "' . $sourceTitle . '" on Skinbase.',
'page_canonical' => $baseUrl,
'page_robots' => 'noindex,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Explore', 'url' => '/explore'],
(object) ['name' => $sourceTitle, 'url' => $sourceUrl],
(object) ['name' => 'Similar Artworks', 'url' => $baseUrl],
]),
]);
}
/**
* GET /art/{id}/similar-results (JSON)
*
* Returns paginated similar artworks asynchronously so the page shell
* can render instantly while this slower query runs in the background.
*/
public function results(Request $request, int $id): JsonResponse
{
$source = Artwork::public()
->published()
->with([
'tags:id,slug',
'categories:id,slug,name',
'categories.contentType:id,name,slug',
'user:id,name,username',
'user.profile:user_id,avatar_hash',
])
->findOrFail($id);
$page = max(1, (int) $request->query('page', 1));
$baseUrl = url("/art/{$id}/similar");
[$artworks, $similaritySource] = $this->resolveSimilarArtworks($source, $page, $baseUrl);
$galleryItems = $artworks->getCollection()->map(fn ($art) => [
'id' => $art->id ?? null,
'name' => $art->name ?? null,
'thumb' => $art->thumb_url ?? $art->thumb ?? null,
'thumb_srcset' => $art->thumb_srcset ?? null,
'uname' => $art->uname ?? '',
'username' => $art->username ?? $art->uname ?? '',
'avatar_url' => $art->avatar_url ?? null,
'category_name' => $art->category_name ?? '',
'category_slug' => $art->category_slug ?? '',
'slug' => $art->slug ?? '',
'width' => $art->width ?? null,
'height' => $art->height ?? null,
'maturity' => $art->maturity ?? null,
])->values();
$galleryItems = collect($this->maturity->filterPayloadItems($galleryItems->all(), $request->user()))->values();
return response()->json([
'data' => $galleryItems,
'similarity_source' => $similaritySource,
'total' => $artworks->total(),
'current_page' => $artworks->currentPage(),
'last_page' => $artworks->lastPage(),
'next_page_url' => $artworks->nextPageUrl(),
'prev_page_url' => $artworks->previousPageUrl(),
]);
}
// ── Similarity resolution ──────────────────────────────────────────────────
/**
* @return array{0: LengthAwarePaginator, 1: string}
*/
private function resolveSimilarArtworks(Artwork $source, int $page, string $baseUrl): array
{
// Priority 1 — Qdrant visual (vision) similarity
if ($this->vectors->isConfigured()) {
$qdrantItems = $this->resolveViaQdrant($source);
if ($qdrantItems !== null && $qdrantItems->isNotEmpty()) {
$paginator = $this->paginateCollection(
$qdrantItems->map(fn ($a) => $this->presentArtwork($a)),
$page,
$baseUrl,
);
return [$paginator, 'visual'];
}
}
// Priority 2 — precomputed hybrid list (tag / behavior / AI)
$hybridItems = $this->hybridService->forArtwork($source->id, self::QDRANT_LIMIT);
if ($hybridItems->isNotEmpty()) {
$paginator = $this->paginateCollection(
$hybridItems->map(fn ($a) => $this->presentArtwork($a)),
$page,
$baseUrl,
);
return [$paginator, 'hybrid'];
}
// Priority 3 — Meilisearch tag/category overlap
$paginator = $this->meilisearchFallback($source, $page);
return [$paginator, 'tags'];
}
/**
* Query Qdrant via VectorGateway, then re-hydrate full Artwork models
* (so we have category/dimension data for the masonry grid).
*
* Returns null when the gateway call fails, so the caller can fall through.
*/
private function resolveViaQdrant(Artwork $source): ?Collection
{
try {
$raw = $this->vectors->similarToArtwork($source, self::QDRANT_LIMIT);
} catch (RuntimeException) {
return null;
}
if (empty($raw)) {
return null;
}
// Preserve Qdrant relevance order; IDs are already filtered to public+published
$orderedIds = array_column($raw, 'id');
$artworks = Artwork::query()
->whereIn('id', $orderedIds)
->where('id', '!=', $source->id) // belt-and-braces exclusion
->public()
->published()
->with([
'categories:id,slug,name',
'categories.contentType:id,name,slug',
'user:id,name,username',
'user.profile:user_id,avatar_hash',
])
->get()
->keyBy('id');
return collect($orderedIds)
->map(fn (int $id) => $artworks->get($id))
->filter()
->values();
}
/**
* Meilisearch tag-overlap query with category fallback.
*/
private function meilisearchFallback(Artwork $source, int $page): LengthAwarePaginator
{
$tagSlugs = $source->tags->pluck('slug')->values()->all();
$categorySlugs = $source->categories->pluck('slug')->values()->all();
$filterParts = [
'is_public = true',
'is_approved = true',
'id != ' . $source->id,
];
if ($tagSlugs !== []) {
$quoted = array_map(fn (string $t): string => 'tags = "' . addslashes($t) . '"', $tagSlugs);
$filterParts[] = '(' . implode(' OR ', $quoted) . ')';
} elseif ($categorySlugs !== []) {
$quoted = array_map(fn (string $c): string => 'category = "' . addslashes($c) . '"', $categorySlugs);
$filterParts[] = '(' . implode(' OR ', $quoted) . ')';
}
$results = Artwork::search('')->options([
'filter' => implode(' AND ', $filterParts),
'sort' => ['trending_score_7d:desc', 'created_at:desc'],
])->paginate(self::PER_PAGE, 'page', $page);
$results->getCollection()->transform(fn ($a) => $this->presentArtwork($a));
return $results;
}
/**
* Wrap a Collection into a LengthAwarePaginator for the view.
*/
private function paginateCollection(
Collection $items,
int $page,
string $path,
): LengthAwarePaginator {
$perPage = self::PER_PAGE;
$total = $items->count();
$slice = $items->forPage($page, $perPage)->values();
return new LengthAwarePaginator($slice, $total, $perPage, $page, [
'path' => $path,
'query' => [],
]);
}
// ── Presenter ─────────────────────────────────────────────────────────────
private function presentArtwork(Artwork $artwork): object
{
$primary = $artwork->categories->sortBy('sort_order')->first();
$present = ThumbnailPresenter::present($artwork, 'md');
$group = $artwork->group;
$isGroupPublisher = $group !== null;
$avatarUrl = $isGroupPublisher
? $group->avatarUrl()
: AvatarUrl::forUser(
(int) ($artwork->user_id ?? 0),
$artwork->user?->profile?->avatar_hash ?? null,
64
);
$displayName = $isGroupPublisher ? ($group->name ?? 'Skinbase') : ($artwork->user?->name ?? 'Skinbase');
$username = $isGroupPublisher ? '' : ($artwork->user?->username ?? '');
$profileUrl = $isGroupPublisher ? $group->publicUrl() : ($username !== '' ? '/@' . $username : null);
return (object) $this->maturity->decoratePayload([
'id' => $artwork->id,
'name' => $artwork->title,
'content_type_name' => $primary?->contentType?->name ?? '',
'content_type_slug' => $primary?->contentType?->slug ?? '',
'category_name' => $primary?->name ?? '',
'category_slug' => $primary?->slug ?? '',
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'uname' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
'published_as_type' => $isGroupPublisher ? 'group' : 'user',
'publisher' => [
'type' => $isGroupPublisher ? 'group' : 'user',
'name' => $displayName,
'username' => $username,
'avatar_url' => $avatarUrl,
'profile_url' => $profileUrl,
],
'published_at' => $artwork->published_at,
'slug' => $artwork->slug ?? '',
'width' => $artwork->width ?? null,
'height' => $artwork->height ?? null,
], $artwork, request()->user());
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Support\Collection;
use Illuminate\View\View;
/**
* StaffController /staff
*
* Displays all users with an elevated role (admin, moderator) grouped by role.
*/
final class StaffController extends Controller
{
/** Roles that appear on the staff page, in display order. */
private const STAFF_ROLES = ['admin', 'moderator'];
public function index(): View
{
/** @var Collection<string, \Illuminate\Support\Collection<int, User>> $staffByRole */
$staffByRole = User::with('profile')
->whereIn('role', self::STAFF_ROLES)
->where('is_active', true)
->orderByRaw("CASE role WHEN 'admin' THEN 0 WHEN 'moderator' THEN 1 ELSE 2 END")
->orderBy('username')
->get()
->groupBy('role');
return view('web.staff', [
'page_title' => 'Staff — Skinbase',
'page_meta_description' => 'Meet the Skinbase team — admins and moderators who keep the community running.',
'page_canonical' => url('/staff'),
'hero_title' => 'Meet the Staff',
'hero_description' => 'The people behind Skinbase who keep the community running smoothly.',
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Staff', 'url' => '/staff'],
]),
'staffByRole' => $staffByRole,
'roleLabels' => [
'admin' => 'Administrators',
'moderator' => 'Moderators',
],
'center_content' => true,
'center_max' => '3xl',
]);
}
}

View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Story;
use App\Models\StoryAuthor;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
/**
* Stories filtered by author /stories/author/{username}
*/
final class StoriesAuthorController extends Controller
{
public function show(Request $request, string $username): View
{
// Resolve by linked user username first, then by author name slug
$author = StoryAuthor::whereHas('user', fn ($q) => $q->where('username', $username))
->with('user')
->first();
if (! $author) {
// Fallback: author name matches slug-style
$author = StoryAuthor::where('name', $username)->first();
}
if (! $author) {
abort(404);
}
$stories = Cache::remember('stories:author:' . $author->id . ':page:' . ($request->get('page', 1)), 300, fn () =>
Story::published()
->with('author', 'tags')
->where('author_id', $author->id)
->orderByDesc('published_at')
->paginate(12)
->withQueryString()
);
$authorName = $author->user?->username ?? $author->name;
return view('web.stories.author', [
'author' => $author,
'stories' => $stories,
'page_title' => 'Stories by ' . $authorName . ' — Skinbase',
'page_meta_description' => 'All stories and interviews by ' . $authorName . ' on Skinbase.',
'page_canonical' => url('/stories/author/' . $username),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Stories', 'url' => '/stories'],
(object) ['name' => $authorName, 'url' => '/stories/author/' . $username],
]),
]);
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Story;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
/**
* Stories listing page /stories
*/
final class StoriesController extends Controller
{
public function index(Request $request): View
{
$featured = Cache::remember('stories:featured', 300, fn () =>
Story::published()->featured()
->with('author', 'tags')
->orderByDesc('published_at')
->first()
);
$stories = Cache::remember('stories:list:page:' . ($request->get('page', 1)), 300, fn () =>
Story::published()
->with('author', 'tags')
->orderByDesc('published_at')
->paginate(12)
->withQueryString()
);
return view('web.stories.index', [
'featured' => $featured,
'stories' => $stories,
'page_title' => 'Stories — Skinbase',
'page_meta_description' => 'Artist interviews, community spotlights, tutorials and announcements from Skinbase.',
'page_canonical' => url('/stories'),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Stories', 'url' => '/stories'],
]),
]);
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Story;
use App\Models\StoryTag;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
/**
* Stories filtered by tag /stories/tag/{tag}
*/
final class StoriesTagController extends Controller
{
public function show(Request $request, string $tag): View
{
$storyTag = StoryTag::where('slug', $tag)->firstOrFail();
$stories = Cache::remember('stories:tag:' . $tag . ':page:' . ($request->get('page', 1)), 300, fn () =>
Story::published()
->with('author', 'tags')
->whereHas('tags', fn ($q) => $q->where('stories_tags.id', $storyTag->id))
->orderByDesc('published_at')
->paginate(12)
->withQueryString()
);
return view('web.stories.tag', [
'storyTag' => $storyTag,
'stories' => $stories,
'page_title' => '#' . $storyTag->name . ' Stories — Skinbase',
'page_meta_description' => 'Stories tagged with "' . $storyTag->name . '" on Skinbase.',
'page_canonical' => url('/stories/tag/' . $storyTag->slug),
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Stories', 'url' => '/stories'],
(object) ['name' => '#' . $storyTag->name, 'url' => '/stories/tag/' . $storyTag->slug],
]),
]);
}
}

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Story;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
/**
* Single story page /stories/{slug}
*/
final class StoryController extends Controller
{
public function show(string $slug): View
{
$story = Cache::remember('stories:' . $slug, 600, fn () =>
Story::published()
->with('author', 'tags')
->where('slug', $slug)
->firstOrFail()
);
// Increment view counter (fire-and-forget, no cache invalidation needed)
Story::where('id', $story->id)->increment('views');
// Related stories: shared tags → same author → newest
$related = Cache::remember('stories:related:' . $story->id, 600, function () use ($story) {
$tagIds = $story->tags->pluck('id');
$related = collect();
if ($tagIds->isNotEmpty()) {
$related = Story::published()
->with('author', 'tags')
->whereHas('tags', fn ($q) => $q->whereIn('stories_tags.id', $tagIds))
->where('id', '!=', $story->id)
->orderByDesc('published_at')
->limit(6)
->get();
}
if ($related->count() < 3 && $story->author_id) {
$byAuthor = Story::published()
->with('author', 'tags')
->where('author_id', $story->author_id)
->where('id', '!=', $story->id)
->whereNotIn('id', $related->pluck('id'))
->orderByDesc('published_at')
->limit(6 - $related->count())
->get();
$related = $related->merge($byAuthor);
}
if ($related->count() < 3) {
$newest = Story::published()
->with('author', 'tags')
->where('id', '!=', $story->id)
->whereNotIn('id', $related->pluck('id'))
->orderByDesc('published_at')
->limit(6 - $related->count())
->get();
$related = $related->merge($newest);
}
return $related->take(6);
});
return view('web.stories.show', [
'story' => $story,
'related' => $related,
'page_title' => $story->title . ' — Skinbase Stories',
'page_meta_description' => $story->meta_excerpt,
'page_canonical' => $story->url,
'page_robots' => 'index,follow',
'breadcrumbs' => collect([
(object) ['name' => 'Stories', 'url' => '/stories'],
(object) ['name' => $story->title, 'url' => $story->url],
]),
]);
}
}

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class StudioHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.studio');
$seo = app(SeoFactory::class)
->collectionPage(
'Studio Help — Skinbase',
'Learn how Studio works on Skinbase Nova, including drafts, publishing, personal versus Group context, artworks, cards, collections, and collaboration workflows.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/StudioHelpPage', [
'title' => 'Studio Help',
'description' => 'Understand Studio as the creative control center of Skinbase Nova, with guidance for drafts, publishing, artworks, cards, collections, and Group workflows.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'open_studio' => route('studio.index'),
'studio_content' => route('studio.content'),
'studio_artworks' => route('studio.artworks'),
'studio_drafts' => route('studio.drafts'),
'studio_scheduled' => route('studio.scheduled'),
'studio_collections' => route('studio.collections'),
'studio_settings' => route('studio.settings'),
'studio_cards' => route('studio.cards.index'),
'create_card' => route('studio.cards.create'),
'upload' => route('upload'),
'upload_help' => route('help.upload'),
'groups_help' => route('help.groups'),
'groups_quickstart' => route('help.groups.quickstart'),
'groups_faq' => route('help.groups.faq'),
'group_studio' => route('studio.groups.index'),
'help_cards' => route('help.cards'),
'help_profile' => route('help.profile'),
'help_auth' => route('help.auth'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,161 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\ContentType;
use App\Models\Tag;
use App\Services\ArtworkSearchService;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\Tags\TagDiscoveryService;
use App\Services\ThumbnailPresenter;
use Illuminate\Http\Request;
use Illuminate\View\View;
final class TagController extends Controller
{
public function __construct(
private readonly ArtworkSearchService $search,
private readonly ArtworkMaturityService $maturity,
private readonly TagDiscoveryService $tagDiscovery,
) {}
public function index(Request $request): View
{
$query = trim((string) $request->query('q', ''));
$featuredTags = $this->tagDiscovery->featuredTags();
$risingTags = $this->tagDiscovery->risingTags($featuredTags);
$tags = $this->tagDiscovery->paginatedTags($query);
$tagStats = $this->tagDiscovery->stats($tags->total());
return view('web.tags.index', [
'tags' => $tags,
'query' => $query,
'featuredTags' => $featuredTags,
'risingTags' => $risingTags,
'tagStats' => $tagStats,
'page_title' => 'Browse Tags — Skinbase',
'page_meta_description' => 'Explore the most-used artwork tags on Skinbase and jump straight into the styles, themes, and aesthetics you want to browse.',
'page_canonical' => route('tags.index'),
'page_robots' => 'index,follow',
]);
}
public function show(Tag $tag, Request $request): View
{
$sort = $request->query('sort', 'popular'); // popular | likes | latest | downloads
$perPage = min((int) $request->query('per_page', 24), 100);
$artworks = $this->search->byTag($tag->slug, $perPage, $sort);
// Eager-load relations used by the gallery presenter and thumbnails.
$artworks->getCollection()->each(fn($m) => $m->loadMissing(['user.profile', 'categories']));
// Sidebar: main content type links (same as browse gallery)
$mainCategories = ContentType::ordered()->get(['name', 'slug'])
->map(fn ($type) => (object) [
'id' => $type->id,
'name' => $type->name,
'slug' => $type->slug,
'url' => '/' . strtolower($type->slug),
]);
// Map artworks into the lightweight shape expected by the gallery React component.
$galleryCollection = collect($this->maturity->filterPayloadItems($artworks->getCollection()->map(function ($a) use ($request): array {
$primaryCategory = $a->categories->sortBy('sort_order')->first();
$present = ThumbnailPresenter::present($a, 'md');
$avatarUrl = \App\Support\AvatarUrl::forUser((int) ($a->user_id ?? 0), $a->user?->profile?->avatar_hash ?? null, 64);
return $this->maturity->decoratePayload([
'id' => $a->id,
'name' => $a->title ?? ($a->name ?? null),
'content_type_name' => $primaryCategory?->contentType?->name ?? '',
'content_type_slug' => $primaryCategory?->contentType?->slug ?? '',
'category_name' => $primaryCategory->name ?? '',
'category_slug' => $primaryCategory->slug ?? '',
'thumb_url' => $present['url'] ?? ($a->thumbUrl('md') ?? null),
'thumb_srcset' => $present['srcset'] ?? null,
'uname' => $a->user?->name ?? '',
'username' => $a->user?->username ?? '',
'avatar_url' => $avatarUrl,
'published_at' => $a->published_at ?? null,
'width' => $a->width ?? null,
'height' => $a->height ?? null,
'slug' => $a->slug ?? null,
], $a, $request->user());
})->values()->all(), $request->user()))
->map(static fn (array $item): object => (object) $item)
->values();
// Replace paginator collection with the gallery-shaped collection so
// the gallery.index blade will generate the expected JSON payload.
if (method_exists($artworks, 'setCollection')) {
$artworks->setCollection($galleryCollection);
}
// Determine gallery sort mapping so the gallery UI highlights the right tab.
$sortMapToGallery = [
'popular' => 'trending',
'latest' => 'latest',
'likes' => 'top-rated',
'downloads' => 'downloaded',
];
$gallerySort = $sortMapToGallery[$sort] ?? 'trending';
$sortLabels = [
'popular' => 'Most viewed',
'likes' => 'Most liked',
'latest' => 'Latest uploads',
'downloads' => 'Most downloaded',
];
$relatedTags = $this->tagDiscovery->relatedTags($tag);
// Build simple pagination SEO links
$prev = method_exists($artworks, 'previousPageUrl') ? $artworks->previousPageUrl() : null;
$next = method_exists($artworks, 'nextPageUrl') ? $artworks->nextPageUrl() : null;
return view('gallery.index', [
'gallery_type' => 'tag',
'mainCategories' => $mainCategories,
'subcategories' => collect(),
'contentType' => null,
'category' => null,
'artworks' => $artworks,
'gallery_nav_section' => 'tags',
'current_sort' => $gallerySort,
'sort_options' => [
['value' => 'trending', 'label' => '🔥 Trending'],
['value' => 'fresh', 'label' => '🆕 New & Hot'],
['value' => 'top-rated', 'label' => '⭐ Top Rated'],
['value' => 'latest', 'label' => '🕐 Latest'],
],
'hero_title' => '#' . $tag->name,
'hero_description' => 'Browse artworks tagged "' . $tag->name . '" and jump between the strongest matching uploads on Skinbase.',
'tag_context' => [
'name' => $tag->name,
'slug' => $tag->slug,
'artworks_total' => $artworks->total(),
'usage_count' => (int) $tag->usage_count,
'current_sort_label' => $sortLabels[$sort] ?? 'Most viewed',
'rss_url' => route('rss.tag', ['slug' => $tag->slug]),
'related_tags' => $relatedTags,
],
'breadcrumbs' => collect([
(object) ['name' => 'Home', 'url' => '/'],
(object) ['name' => 'Tags', 'url' => route('tags.index')],
(object) ['name' => $tag->name, 'url' => route('tags.show', $tag->slug)],
]),
'page_title' => 'Artworks tagged "' . $tag->name . '" — Skinbase',
'page_meta_description' => 'Browse all Skinbase artworks tagged "' . $tag->name . '".',
'page_meta_keywords' => $tag->slug . ', skinbase, artworks, tag',
'page_canonical' => route('tags.show', $tag->slug),
'page_rel_prev' => $prev,
'page_rel_next' => $next,
'page_robots' => 'index,follow',
]);
}
}

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class TroubleshootingHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.troubleshooting');
$seo = app(SeoFactory::class)
->collectionPage(
'Troubleshooting Help — Skinbase',
'Use fast, support-oriented troubleshooting guidance for login issues, permissions confusion, publishing blockers, profile setup problems, and bug-report escalation on Skinbase Nova.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/TroubleshootingHelpPage', [
'title' => 'Troubleshooting Help',
'description' => 'Use diagnosis-first help when something feels broken, blocked, or unclear and you need the fastest next step instead of a long module guide.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'help_auth' => route('help.auth'),
'help_account' => route('help.account'),
'help_profile' => route('help.profile'),
'studio_help' => route('help.studio'),
'upload_help' => route('help.upload'),
'groups_help' => route('help.groups'),
'groups_faq' => route('help.groups.faq'),
'profile_settings' => route('dashboard.profile'),
'open_studio' => route('studio.index'),
'login' => route('login'),
'register' => route('register'),
'password_request' => route('password.request'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
final class UploadHelpPageController extends Controller
{
public function __invoke(Request $request): Response
{
$canonical = route('help.upload');
$seo = app(SeoFactory::class)
->collectionPage(
'Upload Help — Skinbase',
'Learn how uploading works on Skinbase Nova, including draft creation, metadata review, previews, personal versus Group context, contributor credit, publishing, and troubleshooting.',
$canonical,
)
->toArray();
$seo['og_type'] = 'article';
return Inertia::render('Help/UploadHelpPage', [
'title' => 'Upload Help',
'description' => 'Understand the full upload workflow on Skinbase Nova, from file submission and draft creation to metadata review, contributor credit, and final publish.',
'seo' => $seo,
'links' => [
'help_home' => route('help'),
'upload' => route('upload'),
'studio_help' => route('help.studio'),
'open_studio' => route('studio.index'),
'studio_artworks' => route('studio.artworks'),
'studio_drafts' => route('studio.drafts'),
'groups_help' => route('help.groups'),
'groups_quickstart' => route('help.groups.quickstart'),
'groups_faq' => route('help.groups.faq'),
'group_studio' => route('studio.groups.index'),
'help_cards' => route('help.cards'),
'help_profile' => route('help.profile'),
'contact_support' => route('contact.show'),
'report_issue' => route('bug-report'),
],
'auth' => [
'signed_in' => $request->user() !== null,
],
])->rootView('collections');
}
}