<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use File;
use App\Http\Requests;
use App\Models\Bus;
use App\Models\Users;
use App\Models\Supir;
use App\Models\Pemesanan;
use Validator;
use App\Http\Controllers\Controller;
use App\User;
use Image;


class RegisterController extends Controller
{
    public function store(Request $request){
        $input = $request->all();

        if($username = DB::table('users')->where('username' , $input['username'])->first()){
            return redirect()->back()->with('info','We are so sorry :( .Username is exists. Please choose another username');
        }else{
            User::create(['username' => $input['username'],'password' => bcrypt($input['password']),'role' => $input['role']])->id;
            return redirect(url('/index'))->with('info','Data User Berhasil ditambah');
        }
    }

}
