<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Carbon\Carbon;
use App\Country;

class PageController extends Controller
{
	public function showAdminPanel(){
		$companies = \App\Company::count();
		$jobs = \App\Job::count();
		$jobApplications = \App\JobApplication::count();
		return view('home',compact(['companies','jobs','jobApplications']));
	}

	public function showIndex(){
		// $engineering = \App\JobCategory::where('name','Engineering')->first()->jobs()->where('expires_at','>',Carbon::now())->limit(2)->get();
		// $skilled = \App\JobCategory::where('name','Skilled Worker')->first()->jobs()->where('expires_at','>',Carbon::now())->limit(2)->get();
		// $semiskilled = \App\JobCategory::where('name','Semi Skilled Worker')->first()->jobs()->where('expires_at','>',Carbon::now())->limit(2)->get();
		// $labour = \App\JobCategory::where('name','Labour Worker')->first()->jobs()->where('expires_at','>',Carbon::now())->limit(2)->get();
		$categories = \App\JobCategory::latest()->get();
		$companies = \App\Company::latest()->get();
		return view('index',compact(['categories','companies']));
	}

	public function showClients(){
		$companies = \App\Company::get();
		return view('clients',compact('companies'));
	}

	public function showCalendar(){
		$calendar = new \App\Calendar(date('n'),date('Y'));
		$nepaliCalendar = new \App\NepaliCalendar;
		$nepaliDate = $nepaliCalendar->eng_to_nep(date('Y'),date('m'),date('d'));
		$englishDate = ['date' => date('d'), 'month' => date('n'), 'year' => date('Y')];
		return view('calendar',compact('calendar','nepaliDate','englishDate'));
	}

	public function showRequirements(){
		$countries = Country::get();
		return view('post-requirements',compact('countries'));
	}

	public function postRequirements(){
		flash('<p style="font-size:1.2rem" class="text-center text-success">Thank you for sending us your requirements. We have recieved your requirements and will reach back to you as soon as possible!</p>')->success();
		return redirect()->back();
	}
}
