50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\User;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\LegacyService;
|
|
use Illuminate\Support\Str;
|
|
|
|
class MembersController extends Controller
|
|
{
|
|
protected LegacyService $legacy;
|
|
|
|
public function __construct(LegacyService $legacy)
|
|
{
|
|
$this->legacy = $legacy;
|
|
}
|
|
|
|
public function photos(Request $request, $id = null)
|
|
{
|
|
$id = (int) ($id ?: 545);
|
|
|
|
$result = $this->legacy->categoryPage('', null, $id);
|
|
if (! $result) {
|
|
return redirect('/');
|
|
}
|
|
|
|
$page_title = $result['page_title'] ?? ($result['category']->category_name ?? 'Members Photos');
|
|
$artworks = $result['artworks'] ?? collect();
|
|
|
|
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 view('web.members.photos', compact('page_title', 'artworks'));
|
|
}
|
|
}
|