This commit is contained in:
2026-03-20 21:17:26 +01:00
parent 1a62fcb81d
commit 29c3ff8572
229 changed files with 13147 additions and 2577 deletions

View File

@@ -3,46 +3,54 @@
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Services\ArtworkService;
use Illuminate\Http\Request;
use App\Services\LegacyService;
use Illuminate\Support\Str;
class MembersController extends Controller
{
protected LegacyService $legacy;
protected ArtworkService $artworks;
public function __construct(LegacyService $legacy)
public function __construct(ArtworkService $artworks)
{
$this->legacy = $legacy;
$this->artworks = $artworks;
}
public function photos(Request $request, $id = null)
{
$id = (int) ($id ?: 545);
$artworks = $this->artworks->getArtworksByContentType('photography', 40);
$result = $this->legacy->categoryPage('', null, $id);
if (! $result) {
return redirect('/');
}
$artworks->getCollection()->load([
'user:id,name,username',
'user.profile:user_id,avatar_hash',
]);
$page_title = $result['page_title'] ?? ($result['category']->category_name ?? 'Members Photos');
$artworks = $result['artworks'] ?? collect();
$artworks->getCollection()->transform(function (Artwork $artwork) {
$primaryCategory = $artwork->categories->sortBy('sort_order')->first();
$present = \App\Services\ThumbnailPresenter::present($artwork, 'md');
if ($artworks && method_exists($artworks, 'getCollection')) {
$artworks->getCollection()->transform(function ($row) {
$row->slug = $row->slug ?? Str::slug($row->name ?? '');
$row->thumb = $row->thumb ?? ($row->thumb_url ?? null);
$row->thumb_srcset = $row->thumb_srcset ?? ($row->thumb_srcset ?? null);
return $row;
});
} elseif (is_iterable($artworks)) {
$artworks = collect($artworks)->map(function ($row) {
$row->slug = $row->slug ?? Str::slug($row->name ?? '');
$row->thumb = $row->thumb ?? ($row->thumb_url ?? null);
$row->thumb_srcset = $row->thumb_srcset ?? ($row->thumb_srcset ?? null);
return $row;
});
}
return (object) [
'id' => $artwork->id,
'name' => $artwork->title,
'slug' => $artwork->slug,
'url' => '/art/' . $artwork->id . '/' . $artwork->slug,
'thumb' => $present['url'],
'thumb_url' => $present['url'],
'thumb_srcset' => $present['srcset'] ?? $present['url'],
'uname' => $artwork->user->name ?? 'Skinbase',
'username' => $artwork->user->username ?? '',
'avatar_url' => \App\Support\AvatarUrl::forUser((int) ($artwork->user->id ?? 0), $artwork->user->profile->avatar_hash ?? null, 64),
'content_type_name' => $primaryCategory?->contentType?->name ?? 'Photography',
'content_type_slug' => $primaryCategory?->contentType?->slug ?? 'photography',
'category_name' => $primaryCategory?->name ?? '',
'category_slug' => $primaryCategory?->slug ?? '',
'width' => $artwork->width,
'height' => $artwork->height,
'published_at' => $artwork->published_at,
];
});
$page_title = 'Member Photos';
return view('web.members.photos', compact('page_title', 'artworks'));
}