<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class InterviewsController extends Controller
{
    public function index(Request $request)
    {
        try {
            $interviews = DB::table('interviews AS t1')
                ->select('t1.id', 't1.headline', 't2.user_id', 't2.uname', 't2.icon')
                ->leftJoin('users AS t2', 't1.username', '=', 't2.uname')
                ->orderByDesc('t1.datum')
                ->limit(60)
                ->get();
        } catch (\Throwable $e) {
            $interviews = collect();
        }

        $page_title = 'Interviews';

        return view('legacy::interviews', compact('interviews', 'page_title'));
    }
}
