<?php

namespace App\Http\Controllers\Dashboard;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class RouteController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index(Request $request, $component = null)
    {
        $view = $component ? "dashboard.{$component}" : 'dashboard.default';
        if (!view()->exists($view)) {
            return redirect()->route('login')->with('error', 'You must log in to enter this page');
        }
        return view('dashboard.route', compact('view'));
    }
}