<?php

namespace App\Http\Controllers\customers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\driver_model;
use App\Models\customers\customersModel;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;


class customers extends Controller
{

	public function index(){
	 	$data['title']="All Customers";
        $data['customers']=DB::select('select * from customers');
	 	return view('customers.customers',$data);
	}
 
	public function maintain_customers(){
	 	return view('customers.maintain_customers');
	}
    public function save_customers(Request $request){
 	
        $data=$request->input();
        $customer = new customersModel;
        $customer->company_name=$data['company_name'];
        $customer->booking_id='';
        $customer->record_id=rand(10000000,99999999);
        $customer->customer_name=$data['customer_name'];
        $customer->customer_phone=$data['customer_phone'];
        $customer->customer_email=$data['customer_email'];
        $customer->priority=$data['priority'];
        $customer->user_discount=$data['user_discount'];
        $customer->username=$data['username'];
        $customer->userpassword=md5($data['userpassword']);
        $customer->address=$data['address'];
        $customer->instructions=$data['instructions'];
        $customer->discount=$data['discount'];
        $customer->total_bookings='0';
        $customer->account_customer='';
        
        $customer->save();
        return redirect('maintain_customers')->with('status',"Customer record inserted successfully");
    
    }

}	