mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
- Company: COMPANY_LEVEL, CUSTOMER_LEVEL (never referenced) - Payment: all 5 PAYMENT_MODE_* constants (never referenced) - Transaction: PENDING (never referenced) RecurringInvoice constants (ACTIVE, ON_HOLD, NONE, COUNT, DATE) are kept as they are used via hardcoded strings in services, factories, and migrations.
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Transaction extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [
|
|
'id',
|
|
];
|
|
|
|
protected $dates = [
|
|
'transaction_date',
|
|
];
|
|
|
|
public const FAILED = 'FAILED';
|
|
|
|
public const SUCCESS = 'SUCCESS';
|
|
|
|
public function payments(): HasMany
|
|
{
|
|
return $this->hasMany(Payment::class);
|
|
}
|
|
|
|
public function invoice(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Invoice::class);
|
|
}
|
|
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
public function isExpired()
|
|
{
|
|
$linkExpiryDays = (int) CompanySetting::getSetting('link_expiry_days', $this->company_id);
|
|
$checkExpiryLinks = CompanySetting::getSetting('automatically_expire_public_links', $this->company_id);
|
|
|
|
$expiryDate = $this->updated_at->addDays($linkExpiryDays);
|
|
|
|
if ($checkExpiryLinks == 'YES' && $this->status == self::SUCCESS && Carbon::now()->format('Y-m-d') > $expiryDate->format('Y-m-d')) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|