59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class PargarSyncLog extends Model
|
|
{
|
|
protected $table = 'pargar_sync_logs';
|
|
|
|
protected $fillable = [
|
|
'customer_id',
|
|
'amount',
|
|
'desc',
|
|
'order_id',
|
|
'withdraw_id',
|
|
'date',
|
|
'type',
|
|
'sync_status',
|
|
'sync_log',
|
|
'pargar_ref',
|
|
'res',
|
|
'data',
|
|
'confirmed_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'confirmed_at' => 'datetime',
|
|
];
|
|
|
|
private static ?bool $hasConfirmedAtColumn = null;
|
|
|
|
/** سازگاری با نصبهایی که هنوز مایگریشن confirmed_at را اجرا نکردهاند */
|
|
public static function hasConfirmedAtColumn(): bool
|
|
{
|
|
if (self::$hasConfirmedAtColumn === null) {
|
|
try {
|
|
self::$hasConfirmedAtColumn = Schema::hasColumn('pargar_sync_logs', 'confirmed_at');
|
|
} catch (\Throwable) {
|
|
self::$hasConfirmedAtColumn = false;
|
|
}
|
|
}
|
|
|
|
return self::$hasConfirmedAtColumn;
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
}
|