reconstruction of the project

This commit is contained in:
root
2026-03-08 16:33:24 -04:00
parent 23b7db1107
commit c8de5f7edc
9157 changed files with 77877 additions and 1073823 deletions
+52 -20
View File
@@ -7,8 +7,10 @@ use App\Models\BaseModel;
class PaymentNotificationLog extends BaseModel
{
protected $table = 'payment_notification_logs';
protected $primaryKey = 'id';
protected $useSoftDeletes = false;
// CI: useTimestamps = false (created_at / sent_at are managed manually)
public $timestamps = false;
protected $fillable = [
'parent_id',
'invoice_id',
@@ -27,30 +29,60 @@ class PaymentNotificationLog extends BaseModel
'created_at',
'sent_at',
];
public $timestamps = false;
public function existsForPeriod(int $parentId, int $year, int $month, string $type): bool
protected $casts = [
'parent_id' => 'integer',
'invoice_id' => 'integer',
'period_year' => 'integer',
'period_month' => 'integer',
'head_fa_notified' => 'boolean',
'balance_snapshot' => 'decimal:2', // adjust precision if needed
'created_at' => 'datetime',
'sent_at' => 'datetime',
];
/* Optional relationships */
public function parent()
{
return $this->where('parent_id', $parentId)
return $this->belongsTo(User::class, 'parent_id');
}
public function invoice()
{
return $this->belongsTo(Invoice::class, 'invoice_id');
}
/**
* Equivalent of CI existsForPeriod()
*/
public static function existsForPeriod(int $parentId, int $year, int $month, string $type): bool
{
return static::query()
->where('parent_id', $parentId)
->where('period_year', $year)
->where('period_month', $month)
->where('type', $type)
->first() !== null;
->exists();
}
public function listLogs(?string $from = null, ?string $to = null, ?string $type = null): array
/**
* Equivalent of CI listLogs()
* $from/$to should be DATETIME strings.
*/
public static function listLogs(?string $from = null, ?string $to = null, ?string $type = null): array
{
$builder = $this->orderBy('sent_at', 'DESC');
if ($from) {
$builder->where('sent_at >=', $from);
}
if ($to) {
$builder->where('sent_at <=', $to);
}
if ($type) {
$builder->where('type', $type);
}
return $builder->findAll();
}
}
$q = static::query()->orderByDesc('sent_at');
if (!empty($from)) {
$q->where('sent_at', '>=', $from);
}
if (!empty($to)) {
$q->where('sent_at', '<=', $to);
}
if (!empty($type)) {
$q->where('type', $type);
}
return $q->get()->toArray();
}
}