prepared and gallery fixes
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\ArtworkService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -36,34 +38,49 @@ class HomeController extends Controller
|
||||
$latestUploads = $this->artworks->getLatestArtworks(20);
|
||||
|
||||
// Forum news (root forum section id 2876)
|
||||
$forumNews = DB::table('forum_topics as t1')
|
||||
->leftJoin('users as u', 't1.user_id', '=', 'u.user_id')
|
||||
->select('t1.topic_id', 't1.topic', 'u.uname', 't1.post_date', 't1.preview')
|
||||
->where('t1.root_id', 2876)
|
||||
->where('t1.privilege', '<', 4)
|
||||
->orderBy('t1.post_date', 'desc')
|
||||
->limit(8)
|
||||
->get();
|
||||
try {
|
||||
$forumNews = DB::table('forum_topics as t1')
|
||||
->leftJoin('users as u', 't1.user_id', '=', 'u.user_id')
|
||||
->select('t1.topic_id', 't1.topic', 'u.uname', 't1.post_date', 't1.preview')
|
||||
->where('t1.root_id', 2876)
|
||||
->where('t1.privilege', '<', 4)
|
||||
->orderBy('t1.post_date', 'desc')
|
||||
->limit(8)
|
||||
->get();
|
||||
} catch (QueryException $e) {
|
||||
Log::warning('Forum topics table missing or DB error when loading forum news', ['exception' => $e->getMessage()]);
|
||||
$forumNews = collect();
|
||||
}
|
||||
|
||||
// Our news (latest site news)
|
||||
$ourNews = DB::table('news as t1')
|
||||
->join('news_categories as c', 't1.category_id', '=', 'c.category_id')
|
||||
->join('users as u', 't1.user_id', '=', 'u.user_id')
|
||||
->selectRaw('t1.news_id, t1.headline, t1.user_id, t1.picture, t1.preview, u.uname, t1.create_date, t1.views, c.category_name, (SELECT COUNT(*) FROM news_comments WHERE news_id = t1.news_id) AS num_comments')
|
||||
->orderBy('t1.create_date', 'desc')
|
||||
->limit(5)
|
||||
->get();
|
||||
try {
|
||||
$ourNews = DB::table('news as t1')
|
||||
->join('news_categories as c', 't1.category_id', '=', 'c.category_id')
|
||||
->join('users as u', 't1.user_id', '=', 'u.user_id')
|
||||
->selectRaw('t1.news_id, t1.headline, t1.user_id, t1.picture, t1.preview, u.uname, t1.create_date, t1.views, c.category_name, (SELECT COUNT(*) FROM news_comments WHERE news_id = t1.news_id) AS num_comments')
|
||||
->orderBy('t1.create_date', 'desc')
|
||||
->limit(5)
|
||||
->get();
|
||||
} catch (QueryException $e) {
|
||||
Log::warning('News table missing or DB error when loading our news', ['exception' => $e->getMessage()]);
|
||||
$ourNews = collect();
|
||||
}
|
||||
|
||||
// Latest forum activity (exclude rootless and news root)
|
||||
$latestForumActivity = DB::table('forum_topics as t1')
|
||||
->selectRaw('t1.topic_id, t1.topic, (SELECT COUNT(*) FROM forum_posts WHERE topic_id = t1.topic_id) AS numPosts')
|
||||
->where('t1.root_id', '<>', 0)
|
||||
->where('t1.root_id', '<>', 2876)
|
||||
->where('t1.privilege', '<', 4)
|
||||
->orderBy('t1.last_update', 'desc')
|
||||
->orderBy('t1.post_date', 'desc')
|
||||
->limit(10)
|
||||
->get();
|
||||
try {
|
||||
$latestForumActivity = DB::table('forum_topics as t1')
|
||||
->selectRaw('t1.topic_id, t1.topic, (SELECT COUNT(*) FROM forum_posts WHERE topic_id = t1.topic_id) AS numPosts')
|
||||
->where('t1.root_id', '<>', 0)
|
||||
->where('t1.root_id', '<>', 2876)
|
||||
->where('t1.privilege', '<', 4)
|
||||
->orderBy('t1.last_update', 'desc')
|
||||
->orderBy('t1.post_date', 'desc')
|
||||
->limit(10)
|
||||
->get();
|
||||
} catch (QueryException $e) {
|
||||
Log::warning('Forum topics table missing or DB error when loading latest forum activity', ['exception' => $e->getMessage()]);
|
||||
$latestForumActivity = collect();
|
||||
}
|
||||
|
||||
return view('web.home', compact(
|
||||
'page_title',
|
||||
|
||||
Reference in New Issue
Block a user