<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable=[
        'title','amount','photo','description'

    ];
    
    
                function dosms($id,$msg) {
                   
                                   //make sure 1 sec sleep any concurrent sending
                                   $id = sprintf("%07d", $id);
            
            $mask = 'NANCE';
            $token = '18|nB3BHLGaLaNQuagv88TVyckmNEqXxV8OdlS9jlRz';
            $api_link = 'https://sms.smsturbine.com/api/v1/sms/send';
            $number = 94776552503;  //Receiver Number
            $messsage = $msg.' '.'INV'.$id; //Message
            
            $chk = curl_init();
            
            $body = [
            	'mask' => $mask,
            	'number' => $number,
            	'message' => $messsage,
            ];
            
            $header = [
            	'Accept: application/json',
            	'Authorization: Bearer ' . $token
            ];
            
            curl_setopt($chk, CURLOPT_URL, $api_link);		//API link
            curl_setopt($chk, CURLOPT_SSL_VERIFYPEER, 1 );
            curl_setopt($chk, CURLOPT_POST, 1);              	//Uing POST method
            curl_setopt($chk, CURLOPT_POSTFIELDS, $body);        //Parameters
            curl_setopt($chk, CURLOPT_HTTPHEADER, $header);      //Header
            curl_setopt($chk, CURLOPT_RETURNTRANSFER, 1 );
            
            $response = curl_exec($chk);
            
            curl_close ($chk);
            
            //you can used echo for show the details
            //print $response;
            //echo $response;
               }
}
