47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Payment;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ApiKeyHalkbank extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Table name
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'api_key_halkbank';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'order_number',
|
|
'billing_username',
|
|
'billing_password',
|
|
];
|
|
|
|
/**
|
|
* Generate unique order number
|
|
*/
|
|
public static function generateOrderNumber(mixed $resource): int
|
|
{
|
|
$order_number = static::firstOrCreate([
|
|
'billing_username' => $resource->billing_username ?? 'asdasd',
|
|
'billing_password' => $resource->billing_password ?? 'asdasd',
|
|
], ['order_number' => '01122017270']);
|
|
|
|
$order_number->update([
|
|
'order_number' => intval($order_number->order_number) + 1,
|
|
]);
|
|
|
|
return (int) $order_number->order_number;
|
|
}
|
|
}
|