102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Response;
|
|
use Schema;
|
|
use Hash;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Libraries\ListHelper;
|
|
|
|
use App\Contracts\OtpLogResourceInterface;
|
|
use App\OtpLogs;
|
|
use App\Helpers\HttpStatusCode;
|
|
use App\Libraries\UuidHelper;
|
|
use App\Helpers\CurrentUserHelper;
|
|
|
|
class OtpLogService implements OtpLogResourceInterface
|
|
{
|
|
|
|
public $otp_log;
|
|
|
|
public $otplog_id;
|
|
|
|
public function store($lcard_id,$data)
|
|
{
|
|
$this->otp_log = new OtpLogs;
|
|
|
|
$this->otp_log->lcard_id = $lcard_id;
|
|
$this->otp_log->otp = $data['otp'];
|
|
$this->otp_log->msisdn = $data['msisdn'];
|
|
$this->otp_log->content = $data['content'];
|
|
$this->otp_log->rcvd_transid = $data['rcvd_transid'];
|
|
$this->otp_log->transid = $data['transid'];
|
|
$this->otp_log->created_at = date('Y-m-d H:i:s');
|
|
if($this->otp_log->save())
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public function getByField($data)
|
|
{
|
|
$this->otp_log = new OtpLogs;
|
|
|
|
foreach ($data as $field => $value) {
|
|
$this->otp_log = $this->otp_log->where($field,$value);
|
|
}
|
|
|
|
$this->otp_log = $this->otp_log->orderBy('created_at','desc');
|
|
return $this->otp_log->get();
|
|
}
|
|
|
|
public function getLastLog($lcard_id)
|
|
{
|
|
$this->otp_log = OtpLogs::where('lcard_id',$lcard_id)
|
|
->orderBy('created_at', 'desc')
|
|
->first();
|
|
|
|
return $this->otp_log;
|
|
}
|
|
|
|
public function getLastLogByNumber($number)
|
|
{
|
|
$this->otp_log = OtpLogs::where('msisdn',$number)
|
|
->orderBy('created_at', 'desc')
|
|
->first();
|
|
|
|
return $this->otp_log;
|
|
}
|
|
|
|
public function setUsed($id)
|
|
{
|
|
$this->otp_log = OtpLogs::where('otplog_id',$id)->first();
|
|
|
|
$this->otp_log->used = 1;
|
|
$this->otp_log->used_at = date('Y-m-d H:i:s');
|
|
|
|
if ($this->otp_log->save())
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function getLastLog_limit($limit,$card_number)
|
|
{
|
|
|
|
$this->otp_log = OtpLogs::where('lcard_id',$card_number)
|
|
->orderBy('created_at', 'desc')
|
|
->limit($limit)
|
|
->get();
|
|
|
|
return $this->otp_log;
|
|
}
|
|
|
|
|
|
}
|