<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\ProfileSekolah;
use File;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $data = ProfileSekolah::first();
        if(file_exists("latest-update.zip")){
            $updates = TRUE;
            $changelog = NULL;
        }else{
            $updates = FALSE;
            if(file_exists(base_path().'/CHANGELOG.txt')){
                $changelog = File::get(base_path().'/CHANGELOG.txt');
            }else{
                $changelog = NULL;
            }
        }
        return view('pages.be.dashboard', compact('data', 'updates', 'changelog'));
    }
}
