update
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Legacy;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BuddiesController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
if (! $user) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$perPage = 50;
|
||||
|
||||
try {
|
||||
$query = DB::table('friends_list as t1')
|
||||
->leftJoin('users as t2', 't1.user_id', '=', 't2.id')
|
||||
->leftJoin('user_profiles as p', 'p.user_id', '=', 't2.id')
|
||||
->where('t1.friend_id', $user->id)
|
||||
->select('t1.id', 't1.user_id', 't1.friend_id', 't2.name as uname', 'p.avatar_hash as icon', 't1.date_added')
|
||||
->orderByDesc('t1.date_added');
|
||||
|
||||
$followers = $query->paginate($perPage)->withQueryString();
|
||||
} catch (\Throwable $e) {
|
||||
$followers = collect();
|
||||
}
|
||||
|
||||
$page_title = ($user->name ?? $user->username ?? 'User') . ': Followers';
|
||||
|
||||
return view('legacy::buddies', compact('followers', 'page_title'));
|
||||
}
|
||||
}
|
||||
62
app/Http/Controllers/Legacy/CategoryRedirectController.php
Normal file
62
app/Http/Controllers/Legacy/CategoryRedirectController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Legacy;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CategoryRedirectController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, string $group, ?string $slug = null, ?string $id = null): RedirectResponse
|
||||
{
|
||||
$groupSlug = strtolower(trim($group, '/'));
|
||||
$slugPart = strtolower(trim((string) $slug, '/'));
|
||||
|
||||
$category = $this->resolveCategory($groupSlug, $slugPart, $id);
|
||||
|
||||
if ($category && $category->contentType) {
|
||||
$target = $category->url;
|
||||
|
||||
if ($request->getQueryString()) {
|
||||
$target .= '?' . $request->getQueryString();
|
||||
}
|
||||
|
||||
return redirect()->to($target, 301);
|
||||
}
|
||||
|
||||
return redirect()->route('categories.index', $request->query(), 301);
|
||||
}
|
||||
|
||||
private function resolveCategory(string $groupSlug, string $slugPart, ?string $id): ?Category
|
||||
{
|
||||
if ($id !== null && ctype_digit((string) $id)) {
|
||||
$category = Category::query()
|
||||
->with('contentType')
|
||||
->find((int) $id);
|
||||
|
||||
if ($category) {
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
|
||||
if ($slugPart !== '') {
|
||||
$category = Category::query()
|
||||
->with('contentType')
|
||||
->where('slug', $slugPart)
|
||||
->whereHas('parent', fn ($query) => $query->where('slug', $groupSlug))
|
||||
->first();
|
||||
|
||||
if ($category) {
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
|
||||
return Category::query()
|
||||
->with('contentType')
|
||||
->where('slug', $groupSlug)
|
||||
->whereNull('parent_id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
@@ -3,48 +3,54 @@
|
||||
namespace App\Http\Controllers\Legacy;
|
||||
|
||||
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',
|
||||
]);
|
||||
|
||||
// categoryPage returns an array with keys used by legacy.browse
|
||||
$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');
|
||||
|
||||
// Ensure artworks include `slug`, `thumb`, and `thumb_srcset` properties expected by the legacy view
|
||||
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('legacy::browse', compact('page_title', 'artworks'));
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Legacy;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MyBuddiesController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
if (! $user) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$perPage = 50;
|
||||
|
||||
try {
|
||||
$query = DB::table('friends_list as t1')
|
||||
->leftJoin('users as t2', 't1.friend_id', '=', 't2.id')
|
||||
->leftJoin('user_profiles as p', 'p.user_id', '=', 't2.id')
|
||||
->where('t1.user_id', $user->id)
|
||||
->select('t1.id', 't1.friend_id', 't1.user_id', 't2.name as uname', 'p.avatar_hash as icon', 't1.date_added')
|
||||
->orderByDesc('t1.date_added');
|
||||
|
||||
$buddies = $query->paginate($perPage)->withQueryString();
|
||||
} catch (\Throwable $e) {
|
||||
$buddies = collect();
|
||||
}
|
||||
|
||||
$page_title = ($user->name ?? $user->username ?? 'User') . ': Following List';
|
||||
|
||||
return view('legacy::mybuddies', compact('buddies', 'page_title'));
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = $request->user();
|
||||
if (! $user) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
try {
|
||||
$deleted = DB::table('friends_list')->where('id', $id)->where('user_id', $user->id)->delete();
|
||||
if ($deleted) {
|
||||
$request->session()->flash('status', 'Removed from following list.');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$request->session()->flash('error', 'Could not remove buddy.');
|
||||
}
|
||||
|
||||
return redirect()->route('legacy.mybuddies');
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class ReceivedCommentsController extends Controller
|
||||
}
|
||||
|
||||
$hits = 33;
|
||||
$page = max(1, (int) $request->query('page', 1));
|
||||
$currentPage = max(1, (int) $request->query('page', 1));
|
||||
|
||||
$base = ArtworkComment::with(['user', 'artwork'])
|
||||
->whereHas('artwork', function ($q) use ($user) {
|
||||
@@ -30,7 +30,7 @@ class ReceivedCommentsController extends Controller
|
||||
|
||||
return view('legacy::received-comments', [
|
||||
'comments' => $comments,
|
||||
'page' => $page,
|
||||
'currentPage' => $currentPage,
|
||||
'hits' => $hits,
|
||||
'total' => $comments->total(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user