mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-20 19:40:59 -04:00
* Adopt Laravel coding style The Laravel framework adopts the PSR-2 coding style with some additions. Laravel apps *should* adopt this coding style as well. However, Shift allows you to customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config to your project. You may use [Shift's .php_cs][2] file as a base. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 * Shift bindings PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser. * Shift core files * Shift to Throwable * Add laravel/ui dependency * Unindent vendor mail templates * Shift config files * Default config files In an effort to make upgrading the constantly changing config files easier, Shift defaulted them so you can review the commit diff for changes. Moving forward, you should use ENV variables or create a separate config file to allow the core config files to remain automatically upgradeable. * Shift Laravel dependencies * Shift cleanup * Upgrade to Laravel 7 Co-authored-by: Laravel Shift <shift@laravelshift.com>
156 lines
3.3 KiB
PHP
156 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://opensource.org/licenses/AAL
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Filterable;
|
|
use App\Utils\Traits\MakesHash;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Class for Recurring Invoices.
|
|
*/
|
|
class RecurringQuote extends BaseModel
|
|
{
|
|
use MakesHash;
|
|
use SoftDeletes;
|
|
use Filterable;
|
|
|
|
/**
|
|
* Invoice Statuses.
|
|
*/
|
|
const STATUS_DRAFT = 2;
|
|
const STATUS_ACTIVE = 3;
|
|
const STATUS_PENDING = -1;
|
|
const STATUS_COMPLETED = -2;
|
|
const STATUS_CANCELLED = -3;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
protected $fillable = [
|
|
'client_id',
|
|
'quote_number',
|
|
'discount',
|
|
'is_amount_discount',
|
|
'po_number',
|
|
'quote_date',
|
|
'valid_until',
|
|
'line_items',
|
|
'settings',
|
|
'footer',
|
|
'public_note',
|
|
'private_notes',
|
|
'terms',
|
|
'tax_name1',
|
|
'tax_name2',
|
|
'tax_name3',
|
|
'tax_rate1',
|
|
'tax_rate2',
|
|
'tax_rate3',
|
|
'custom_value1',
|
|
'custom_value2',
|
|
'custom_value3',
|
|
'custom_value4',
|
|
'amount',
|
|
'frequency_id',
|
|
'start_date',
|
|
];
|
|
|
|
protected $touches = [];
|
|
|
|
protected $casts = [
|
|
'line_items' => 'object',
|
|
'backup' => 'object',
|
|
'settings' => 'object',
|
|
'updated_at' => 'timestamp',
|
|
'created_at' => 'timestamp',
|
|
'deleted_at' => 'timestamp',
|
|
];
|
|
|
|
protected $with = [
|
|
// 'client',
|
|
// 'company',
|
|
];
|
|
|
|
public function getEntityType()
|
|
{
|
|
return self::class;
|
|
}
|
|
|
|
public function getDateAttribute($value)
|
|
{
|
|
if (! empty($value)) {
|
|
return (new Carbon($value))->format('Y-m-d');
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
public function getDueDateAttribute($value)
|
|
{
|
|
if (! empty($value)) {
|
|
return (new Carbon($value))->format('Y-m-d');
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
public function getPartialDueDateAttribute($value)
|
|
{
|
|
if (! empty($value)) {
|
|
return (new Carbon($value))->format('Y-m-d');
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
public function company()
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
public function client()
|
|
{
|
|
return $this->belongsTo(Client::class)->withTrashed();
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class)->withTrashed();
|
|
}
|
|
|
|
public function assigned_user()
|
|
{
|
|
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
|
}
|
|
|
|
public function invitations()
|
|
{
|
|
$this->morphMany(RecurringQuoteInvitation::class);
|
|
}
|
|
}
|