current state
This commit is contained in:
@@ -44,10 +44,10 @@ class LegacyController extends Controller
|
||||
$perPage = 50;
|
||||
|
||||
try {
|
||||
$artworks = DB::connection('legacy')->table('wallz as w')
|
||||
->leftJoin('artworks_categories as c', 'w.category', '=', 'c.category_id')
|
||||
$artworks = DB::table('wallz as w')
|
||||
->leftJoin('categories as c', 'w.category', '=', 'c.id')
|
||||
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
|
||||
->select('w.id', 'w.name', 'w.picture', 'w.category', 'w.datum', 'c.category_name', 'u.uname')
|
||||
->select('w.id', 'w.name', 'w.picture', 'w.category', 'w.datum', DB::raw('c.name as category_name'), 'u.uname')
|
||||
->where('w.approved', 1)
|
||||
->where('w.public', 'Y')
|
||||
->orderByDesc('w.datum')
|
||||
@@ -101,10 +101,10 @@ class LegacyController extends Controller
|
||||
$page_meta_description = $group . ' artworks on Skinbase';
|
||||
$page_meta_keywords = strtolower($group) . ', skinbase, artworks, wallpapers, photography, skins';
|
||||
|
||||
try {
|
||||
$category = DB::connection('legacy')->table('artworks_categories')
|
||||
->select('category_id', 'category_name', 'description', 'rootid', 'section_id')
|
||||
->where('category_id', $id)
|
||||
try {
|
||||
$category = DB::table('categories')
|
||||
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'description', DB::raw('parent_id as rootid'), DB::raw('content_type_id as section_id'))
|
||||
->where('id', $id)
|
||||
->first();
|
||||
} catch (\Throwable $e) {
|
||||
$category = null;
|
||||
@@ -117,9 +117,9 @@ class LegacyController extends Controller
|
||||
$perPage = 40;
|
||||
|
||||
try {
|
||||
$base = DB::connection('legacy')->table('wallz as t1')
|
||||
->select('t1.id', 't1.name', 't1.picture', 't3.uname', 't1.category', 't2.category_name')
|
||||
->join('artworks_categories as t2', 't1.category', '=', 't2.category_id')
|
||||
$base = DB::table('wallz as t1')
|
||||
->select('t1.id', 't1.name', 't1.picture', 't3.uname', 't1.category', DB::raw('t2.name as category_name'))
|
||||
->join('categories as t2', 't1.category', '=', 't2.id')
|
||||
->leftJoin('users as t3', 't1.user_id', '=', 't3.user_id')
|
||||
->where('t1.approved', 1)
|
||||
->where(function ($q) use ($id, $category) {
|
||||
@@ -139,22 +139,22 @@ class LegacyController extends Controller
|
||||
}
|
||||
|
||||
try {
|
||||
$subcategories = DB::connection('legacy')->table('artworks_categories')
|
||||
->select('category_id', 'category_name')
|
||||
->where('rootid', $id)
|
||||
$subcategories = DB::table('categories')
|
||||
->select(DB::raw('id as category_id'), DB::raw('name as category_name'))
|
||||
->where('parent_id', $id)
|
||||
->orderBy('category_name')
|
||||
->get();
|
||||
|
||||
if ($subcategories->isEmpty() && $category->rootid) {
|
||||
$subcategories = DB::connection('legacy')->table('artworks_categories')
|
||||
->select('category_id', 'category_name')
|
||||
->where('rootid', $category->rootid)
|
||||
$subcategories = DB::table('categories')
|
||||
->select(DB::raw('id as category_id'), DB::raw('name as category_name'))
|
||||
->where('parent_id', $category->rootid)
|
||||
->orderBy('category_name')
|
||||
->get();
|
||||
}
|
||||
|
||||
if ($subcategories->isEmpty()) {
|
||||
$subcategories = DB::connection('legacy')->table('skupine')
|
||||
$subcategories = DB::table('skupine')
|
||||
->select('category_id', 'category_name')
|
||||
->where('rootid', $id)
|
||||
->orderBy('category_name')
|
||||
@@ -162,7 +162,7 @@ class LegacyController extends Controller
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
try {
|
||||
$subcategories = DB::connection('legacy')->table('skupine')
|
||||
$subcategories = DB::table('skupine')
|
||||
->select('category_id', 'category_name')
|
||||
->where('rootid', $id)
|
||||
->orderBy('category_name')
|
||||
@@ -191,16 +191,16 @@ class LegacyController extends Controller
|
||||
|
||||
// Load top-level categories (section_id = 0 AND rootid = 0) like the legacy page
|
||||
try {
|
||||
$categories = DB::connection('legacy')->table('artworks_categories')
|
||||
->select('category_id', 'category_name', 'description')
|
||||
->where('section_id', 0)
|
||||
->where('rootid', 0)
|
||||
->orderBy('category_id')
|
||||
$categories = DB::table('categories')
|
||||
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'description')
|
||||
->where('content_type_id', 0)
|
||||
->where(DB::raw('parent_id'), 0)
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
// Fallback to legacy table name if empty
|
||||
if ($categories->isEmpty()) {
|
||||
$categories = DB::connection('legacy')->table('skupine')
|
||||
$categories = DB::table('skupine')
|
||||
->select('category_id', 'category_name', 'description')
|
||||
->where('section_id', 0)
|
||||
->where('rootid', 0)
|
||||
@@ -209,7 +209,7 @@ class LegacyController extends Controller
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
try {
|
||||
$categories = DB::connection('legacy')->table('skupine')
|
||||
$categories = DB::table('skupine')
|
||||
->select('category_id', 'category_name', 'description')
|
||||
->where('section_id', 0)
|
||||
->where('rootid', 0)
|
||||
@@ -225,15 +225,15 @@ class LegacyController extends Controller
|
||||
if ($categories->isNotEmpty()) {
|
||||
$ids = $categories->pluck('category_id')->unique()->values()->all();
|
||||
try {
|
||||
$subs = DB::connection('legacy')->table('artworks_categories')
|
||||
->select('category_id', 'category_name', 'picture', 'section_id')
|
||||
->whereIn('section_id', $ids)
|
||||
$subs = DB::table('categories')
|
||||
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'image as picture', DB::raw('content_type_id as section_id'))
|
||||
->whereIn('content_type_id', $ids)
|
||||
->orderBy('category_name')
|
||||
->get();
|
||||
|
||||
if ($subs->isEmpty()) {
|
||||
// fallback to skupine table naming
|
||||
$subs = DB::connection('legacy')->table('skupine')
|
||||
$subs = DB::table('skupine')
|
||||
->select('category_id', 'category_name', 'picture', 'section_id')
|
||||
->whereIn('section_id', $ids)
|
||||
->orderBy('category_name')
|
||||
@@ -262,7 +262,7 @@ class LegacyController extends Controller
|
||||
$page_meta_keywords = 'forum, discussions, topics, skinbase';
|
||||
|
||||
try {
|
||||
$topics = DB::connection('legacy')->table('forum_topics as t')
|
||||
$topics = DB::table('forum_topics as t')
|
||||
->select(
|
||||
't.topic_id',
|
||||
't.topic',
|
||||
@@ -292,7 +292,7 @@ class LegacyController extends Controller
|
||||
public function forumTopic(Request $request, int $topic_id)
|
||||
{
|
||||
try {
|
||||
$topic = DB::connection('legacy')->table('forum_topics')->where('topic_id', $topic_id)->first();
|
||||
$topic = DB::table('forum_topics')->where('topic_id', $topic_id)->first();
|
||||
} catch (\Throwable $e) {
|
||||
$topic = null;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ class LegacyController extends Controller
|
||||
|
||||
// Fetch subtopics; if none exist, fall back to posts (matches legacy behavior where some topics hold posts directly)
|
||||
try {
|
||||
$subtopics = DB::connection('legacy')->table('forum_topics as t')
|
||||
$subtopics = DB::table('forum_topics as t')
|
||||
->leftJoin('users as u', 't.user_id', '=', 'u.user_id')
|
||||
->select(
|
||||
't.topic_id',
|
||||
@@ -348,7 +348,7 @@ class LegacyController extends Controller
|
||||
]);
|
||||
|
||||
try {
|
||||
$posts = DB::connection('legacy')->table('forum_posts as p')
|
||||
$posts = DB::table('forum_posts as p')
|
||||
->leftJoin('users as u', 'p.user_id', '=', 'u.user_id')
|
||||
->select('p.id', 'p.message', 'p.post_date', 'u.uname', 'u.user_id', 'u.icon', 'u.eicon')
|
||||
->where('p.topic_id', $topic->topic_id)
|
||||
@@ -361,7 +361,7 @@ class LegacyController extends Controller
|
||||
|
||||
if ($posts->total() === 0) {
|
||||
try {
|
||||
$posts = DB::connection('legacy')->table('forum_posts as p')
|
||||
$posts = DB::table('forum_posts as p')
|
||||
->leftJoin('users as u', 'p.user_id', '=', 'u.user_id')
|
||||
->select('p.id', 'p.message', 'p.post_date', 'u.uname', 'u.user_id', 'u.icon', 'u.eicon')
|
||||
->where('p.tid', $topic->topic_id)
|
||||
@@ -391,14 +391,14 @@ class LegacyController extends Controller
|
||||
$memberFeatured = null;
|
||||
|
||||
try {
|
||||
$featured = DB::connection('legacy')->table('featured_works as fw')
|
||||
$featured = DB::table('featured_works as fw')
|
||||
->leftJoin('wallz as w', 'fw.artwork_id', '=', 'w.id')
|
||||
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
|
||||
->select('w.id', 'w.name', 'w.picture', 'u.uname', 'fw.post_date')
|
||||
->orderByDesc('fw.post_date')
|
||||
->first();
|
||||
|
||||
$memberFeatured = DB::connection('legacy')->table('users_opinions as o')
|
||||
$memberFeatured = DB::table('users_opinions as o')
|
||||
->leftJoin('wallz as w', 'o.artwork_id', '=', 'w.id')
|
||||
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
|
||||
->select(DB::raw('COUNT(*) AS votes'), 'w.id', 'w.name', 'w.picture', 'u.uname')
|
||||
@@ -437,7 +437,7 @@ class LegacyController extends Controller
|
||||
private function forumNews(): array
|
||||
{
|
||||
try {
|
||||
return DB::connection('legacy')->table('forum_topics as t1')
|
||||
return DB::table('forum_topics as t1')
|
||||
->leftJoin('users as t2', 't1.user_id', '=', 't2.user_id')
|
||||
->select(
|
||||
't1.topic_id',
|
||||
@@ -461,7 +461,7 @@ class LegacyController extends Controller
|
||||
private function ourNews(): array
|
||||
{
|
||||
try {
|
||||
return DB::connection('legacy')->table('news as t1')
|
||||
return DB::table('news as t1')
|
||||
->join('news_categories as t2', 't1.category_id', '=', 't2.category_id')
|
||||
->join('users as t3', 't1.user_id', '=', 't3.user_id')
|
||||
->select(
|
||||
@@ -487,7 +487,7 @@ class LegacyController extends Controller
|
||||
private function latestForumActivity(): array
|
||||
{
|
||||
try {
|
||||
return DB::connection('legacy')->table('forum_topics as t1')
|
||||
return DB::table('forum_topics as t1')
|
||||
->select(
|
||||
't1.topic_id',
|
||||
't1.topic',
|
||||
@@ -523,9 +523,9 @@ class LegacyController extends Controller
|
||||
// Fallback to DB if cache missing
|
||||
if (empty($uploads)) {
|
||||
try {
|
||||
$uploads = DB::connection('legacy')->table('wallz as w')
|
||||
$uploads = DB::table('wallz as w')
|
||||
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
|
||||
->leftJoin('artworks_categories as c', 'w.category', '=', 'c.category_id')
|
||||
->leftJoin('categories as c', 'w.category', '=', 'c.id')
|
||||
->where('w.approved', 1)
|
||||
->orderByDesc('w.datum')
|
||||
->limit(20)
|
||||
@@ -536,7 +536,7 @@ class LegacyController extends Controller
|
||||
'name' => $row->name,
|
||||
'picture' => $row->picture,
|
||||
'uname' => $row->uname,
|
||||
'category_name' => $row->category_name ?? '',
|
||||
'category_name' => $row->category_name ?? $row->name ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
Reference in New Issue
Block a user