sms intregation by laravel

  protected function createCustomer(Request $request)

    {

       

$frontDesign=Websitefrontdesign::first();

 

if($request->password != $request->re_password)

{

return redirect()->route('register')->with('error_message', 'Password Not Matched,Please Try Again.');

}

if($request->customer_email != null)

{

$customer_email=$request->customer_email;

    $checkIfCutomerEmailExist=Customer::where('customer_email',$request->customer_email)->first();

    if($checkIfCutomerEmailExist != null)

    {

    return redirect()->route('register')->with('error_message', 'Email Already Exist Please,Give Differnt Email Address.');

    }

}

else

{

$customer_email="";

}

$checkIfCutomerUserNameExist=Customer::where('customer_username',$request->customer_username)->first();

     

if($checkIfCutomerUserNameExist != null)

{

return redirect()->route('register')->with('error_message', 'Username Already Exist Please,Give Differnt User Name.');

  $otp_code=rand ( 1000 , 9999 );

 

        $cutomer = Customer::create([

            'customer_name' => $request->customer_name,

            'customer_username' => $request->customer_username,

            'customer_email' => $customer_email,

            'otp_code' => $otp_code,

            'password' => bcrypt($request->password),

'customer_token' => Crypt::encryptString($request->password),

            'status' => "1",

            'customer_basicinfo' => "0",

'created_at' => date('Y-m-d H:i:s'),

            

        ]);   

    $to = $request->customer_username;

    $message = "Your verification code for". $frontDesign->site_name ." : ".$otp_code;   

    $apiKey='0dee054cbc47eb07';

    $secretkey='f9a4d834';

    $callerID=urlencode('1936');

    $toUser=$to;

    $messageContent=urlencode($message);

    

    $response=file_get_contents('https://smpp.ajuratech.com:7790/sendtext?apikey='.$apiKey.'&secretkey='.$secretkey.'&callerID='.$callerID.'&toUser='.$toUser.'&messageContent='.$messageContent);

    // echo $response;


if($cutomer)

{

            if (Auth::guard('customer')->attempt(['customer_username' => $request->customer_username, 'password' => $request->password])) {

            return redirect()->route('customer.dashboard')->with('success_message', 'You are success fully loged In');

            } else {

             return redirect()->back()->with('error_message', 'Invalid Username or Password');

            }

            return redirect()->route('login')->with('success_message', 'Success Fully Registered,Please Login.');

}

else

{

return redirect()->back()->with('error_message', 'Invalid Username or Password');

}

    }

}

Comments

Popular posts from this blog

date wise search codeigniter

all customer due sql query