optimizations
This commit is contained in:
253
app/Http/Controllers/Web/CollectionDiscoveryController.php
Normal file
253
app/Http/Controllers/Web/CollectionDiscoveryController.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?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 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));
|
||||
|
||||
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' => [
|
||||
'title' => 'Search Collections — Skinbase Nova',
|
||||
'description' => 'Search public collections by category, theme, quality tier, and curator context.',
|
||||
'canonical' => route('collections.search'),
|
||||
'robots' => 'index,follow',
|
||||
],
|
||||
'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);
|
||||
|
||||
return Inertia::render('Collection/CollectionFeaturedIndex', [
|
||||
'eyebrow' => 'Program',
|
||||
'title' => $program['label'],
|
||||
'description' => $program['description'],
|
||||
'seo' => [
|
||||
'title' => sprintf('%s — Skinbase Nova', $program['label']),
|
||||
'description' => $program['description'],
|
||||
'canonical' => route('collections.program.show', ['programKey' => $program['key']]),
|
||||
'robots' => 'index,follow',
|
||||
],
|
||||
'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,
|
||||
) {
|
||||
return Inertia::render('Collection/CollectionFeaturedIndex', [
|
||||
'eyebrow' => $eyebrow,
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'seo' => [
|
||||
'title' => sprintf('%s — Skinbase Nova', $title),
|
||||
'description' => $description,
|
||||
'canonical' => url()->current(),
|
||||
'robots' => 'index,follow',
|
||||
],
|
||||
'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');
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ 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\FeedBlender;
|
||||
use App\Services\EarlyGrowth\GridFiller;
|
||||
use App\Services\Recommendation\RecommendationService;
|
||||
use App\Services\Recommendations\RecommendationFeedResolver;
|
||||
use App\Services\UserSuggestionService;
|
||||
use App\Services\ThumbnailPresenter;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@@ -31,9 +33,11 @@ final class DiscoverController extends Controller
|
||||
public function __construct(
|
||||
private readonly ArtworkService $artworkService,
|
||||
private readonly ArtworkSearchService $searchService,
|
||||
private readonly RecommendationService $recoService,
|
||||
private readonly RecommendationFeedResolver $feedResolver,
|
||||
private readonly FeedBlender $feedBlender,
|
||||
private readonly GridFiller $gridFiller,
|
||||
private readonly CommunityActivityService $communityActivity,
|
||||
private readonly UserSuggestionService $userSuggestions,
|
||||
) {}
|
||||
|
||||
// ─── /discover/trending ──────────────────────────────────────────────────
|
||||
@@ -225,51 +229,38 @@ final class DiscoverController extends Controller
|
||||
/**
|
||||
* Personalised "For You" feed page.
|
||||
*
|
||||
* Uses RecommendationService (Phase 1 tag-affinity + creator-affinity pipeline)
|
||||
* and renders the standard discover grid view. Guest users are redirected
|
||||
* to the trending page per spec.
|
||||
* 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 = 40;
|
||||
$limit = max(1, min(50, (int) $request->query('limit', 40)));
|
||||
$cursor = $request->query('cursor') ?: null;
|
||||
|
||||
// Retrieve the paginated feed (service handles Meilisearch + reranking + cache)
|
||||
$feedResult = $this->recoService->forYouFeed(
|
||||
user: $user,
|
||||
limit: $limit,
|
||||
$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,
|
||||
);
|
||||
|
||||
$artworkItems = $feedResult['data'] ?? [];
|
||||
|
||||
// Build a simple presentable collection
|
||||
$artworks = collect($artworkItems)->map(function (array $item) {
|
||||
$width = isset($item['width']) && $item['width'] > 0 ? (int) $item['width'] : null;
|
||||
$height = isset($item['height']) && $item['height'] > 0 ? (int) $item['height'] : null;
|
||||
$avatarUrl = \App\Support\AvatarUrl::forUser((int) ($item['author_id'] ?? 0), null, 64);
|
||||
|
||||
return (object) [
|
||||
'id' => $item['id'] ?? 0,
|
||||
'name' => $item['title'] ?? 'Untitled',
|
||||
'category_name' => $item['category_name'] ?? '',
|
||||
'category_slug' => $item['category_slug'] ?? '',
|
||||
'thumb_url' => $item['thumbnail_url'] ?? null,
|
||||
'thumb_srcset' => $item['thumbnail_url'] ?? null,
|
||||
'uname' => $item['author'] ?? 'Artist',
|
||||
'username' => $item['username'] ?? '',
|
||||
'avatar_url' => $avatarUrl,
|
||||
'published_at' => $item['published_at'] ?? null,
|
||||
'slug' => $item['slug'] ?? '',
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
];
|
||||
});
|
||||
$artworks = collect($feedResult['data'] ?? [])->map(
|
||||
fn (array $item) => $this->presentRecommendedArtwork($item)
|
||||
)->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',
|
||||
@@ -277,6 +268,7 @@ final class DiscoverController extends Controller
|
||||
'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,
|
||||
]);
|
||||
}
|
||||
@@ -304,20 +296,7 @@ final class DiscoverController extends Controller
|
||||
}
|
||||
|
||||
// Suggested creators: most-followed users the viewer doesn't follow yet
|
||||
$suggestedCreators = DB::table('users')
|
||||
->join('user_statistics', 'users.id', '=', 'user_statistics.user_id')
|
||||
->where('users.id', '!=', $user->id)
|
||||
->whereNotNull('users.email_verified_at')
|
||||
->where('users.is_active', true)
|
||||
->orderByDesc('user_statistics.followers_count')
|
||||
->limit(8)
|
||||
->select(
|
||||
'users.id',
|
||||
'users.name',
|
||||
'users.username',
|
||||
'user_statistics.followers_count',
|
||||
)
|
||||
->get();
|
||||
$suggestedCreators = $this->userSuggestions->suggestFor($user, 6);
|
||||
|
||||
return view('web.discover.index', [
|
||||
'artworks' => collect(),
|
||||
@@ -328,6 +307,9 @@ final class DiscoverController extends Controller
|
||||
'empty' => true,
|
||||
'fallback_trending' => $fallbackArtworks,
|
||||
'fallback_creators' => $suggestedCreators,
|
||||
'following_activity' => [],
|
||||
'network_trending' => [],
|
||||
'suggested_users' => $suggestedCreators,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -347,12 +329,23 @@ final class DiscoverController extends Controller
|
||||
|
||||
$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),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -443,4 +436,81 @@ final class DiscoverController extends Controller
|
||||
'height' => $artwork->height ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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')
|
||||
->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();
|
||||
}
|
||||
}
|
||||
|
||||
1243
app/Http/Controllers/Web/NovaCardsController.php
Normal file
1243
app/Http/Controllers/Web/NovaCardsController.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user