<?php

namespace App\Http\Controllers;

use App\Models\AccountCurrency;
use App\Models\AccountType;
use Illuminate\Http\Request;

class PageController extends Controller
{
    public function index()
    {

        return view('landing.virginIndex');
    }

    public function accounts()
    {
        return view('landing.accounts');
    }

    public function about()
    {
        return view('landing.about');
    }

    public function loan()
    {
        return view('landing.loan');
    }

    public function contact()
    {
        return view('landing.contact');
    }

    public function agreement()
    {
        return redirect(route('register'));
    }
    public function signup()
    {
        $currencies = AccountCurrency::all();
        $account_types = AccountType::all();
        return view('auth.onlineapplication', compact('currencies', 'account_types'));
    }
    public function login()
    {
        return view('auth.login');
    }
    public function adminLogin()
    {
        return view('auth.admin-login');
    }
    public function authentication()
    {
        if (session()->has('user_id')) {
            session()->keep(['user_id','firstname','lastname','profile_picture']);
            return view('auth.authentication');
        }
        return redirect('auth/login');
    }
    public function authSuccess()
    {
        if (session('auth.success')) {
            return view('auth.success');
        } else {
            return redirect(route('user.login'))->withErrors('error', 'Something went wrong please try again');
        }
    }
}
