1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Models/RecurringInvoice.php

78 lines
1.5 KiB
PHP
Raw Normal View History

2019-04-23 14:22:13 +02:00
<?php
namespace App\Models;
use App\Models\Filterable;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
2019-05-03 00:29:04 +02:00
/**
* Class for Recurring Invoices.
*/
2019-04-23 14:22:13 +02:00
class RecurringInvoice extends BaseModel
{
use MakesHash;
use SoftDeletes;
use Filterable;
2019-05-03 00:29:04 +02:00
/**
* Invoice Statuses
*/
2019-05-03 09:35:49 +02:00
const STATUS_DRAFT = 2;
const STATUS_ACTIVE = 3;
const STATUS_PENDING = -1;
const STATUS_COMPLETED = -2;
const STATUS_CANCELLED = -3;
2019-05-03 00:29:04 +02:00
/**
* Recurring intervals
*/
const FREQUENCY_WEEKLY = 1;
const FREQUENCY_TWO_WEEKS = 2;
const FREQUENCY_FOUR_WEEKS = 3;
const FREQUENCY_MONTHLY = 4;
const FREQUENCY_TWO_MONTHS = 5;
const FREQUENCY_THREE_MONTHS = 6;
const FREQUENCY_FOUR_MONTHS = 7;
const FREQUENCY_SIX_MONTHS = 8;
const FREQUENCY_ANNUALLY = 9;
const FREQUENCY_TWO_YEARS = 10;
const RECURS_INDEFINITELY = 1;
2019-04-23 14:22:13 +02:00
protected $guarded = [
'id',
];
protected $casts = [
'settings' => 'object'
];
2019-05-03 00:29:04 +02:00
protected $with = [
2019-05-03 03:30:08 +02:00
// 'client',
// 'company',
2019-05-03 00:29:04 +02:00
];
2019-04-23 14:22:13 +02:00
public function company()
{
return $this->belongsTo(Company::class);
}
2019-05-03 00:29:04 +02:00
public function client()
{
return $this->belongsTo(Client::class);
}
2019-04-23 14:22:13 +02:00
public function user()
{
return $this->belongsTo(User::class);
}
public function invitations()
{
2019-04-24 02:22:02 +02:00
$this->morphMany(RecurringInvoiceInvitation::class);
2019-04-23 14:22:13 +02:00
}
}