| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/app.machinox.in/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use stdClass;
class AdminOtp extends Model
{
use HasFactory;
protected $fillable = ['admin_id', 'otp', 'expired_at'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['created_at', 'updated_at'];
public static function SendOTP($adminId ,$otpType = null)
{
// $otp = rand(000000, 999999);
$otp = "123456";
$expired_at = date("Y-m-d H:i:s", strtotime("+10 minutes"));
$uniqueToken = hash('sha256', Str::random(60));
if ($adminId) {
$otpInfo = AdminOtp::where("admin_id", $adminId)->first();
if (!$otpInfo) {
$otpInfo = new AdminOtp;
}
}
$otpInfo->admin_id = $adminId;
$otpInfo->ref_no = Uuid::uuid4();
$otpInfo->otp = $otp;
$otpInfo->expired_at = $expired_at;
$otpInfo->save();
$user = AdminUser::find($adminId);
$user->remember_token = $uniqueToken;
$user->save();
// EmailHelper::sendPasswordResetOtp($otp);
$res = new stdClass;
$res->id = $otpInfo->id;
$res->otp = $otpInfo->otp;
$res->message = trans("messages.OTP_SENT_SUCCESSFULLY");
return $res;
}
}