2018-10-15 23:40:34 +11:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2019-04-04 12:38:17 +11:00
|
|
|
use App\Models\Filterable;
|
2018-11-20 15:36:56 +11:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-15 23:40:34 +11:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2019-04-04 12:38:17 +11:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-10-15 23:40:34 +11:00
|
|
|
|
2018-11-02 21:54:46 +11:00
|
|
|
class Invoice extends BaseModel
|
2018-10-15 23:40:34 +11:00
|
|
|
{
|
2018-11-20 15:36:56 +11:00
|
|
|
use MakesHash;
|
2019-04-04 12:38:17 +11:00
|
|
|
use SoftDeletes;
|
|
|
|
|
use Filterable;
|
|
|
|
|
|
2018-11-20 15:36:56 +11:00
|
|
|
protected $guarded = [
|
|
|
|
|
'id',
|
|
|
|
|
];
|
|
|
|
|
|
2019-04-17 16:20:32 +10:00
|
|
|
protected $casts = [
|
|
|
|
|
'settings' => 'object'
|
|
|
|
|
];
|
|
|
|
|
|
2019-04-25 17:16:41 +10:00
|
|
|
protected $with = [
|
|
|
|
|
'company'
|
|
|
|
|
];
|
|
|
|
|
|
2019-04-04 10:30:49 +11:00
|
|
|
const STATUS_DRAFT = 1;
|
2019-04-28 20:25:18 +10:00
|
|
|
const STATUS_SENT = 2;
|
2019-04-04 10:30:49 +11:00
|
|
|
const STATUS_PARTIAL = 5;
|
|
|
|
|
const STATUS_PAID = 6;
|
2019-04-28 20:25:18 +10:00
|
|
|
const STATUS_CANCELLED = 8;
|
2019-04-23 14:16:41 +10:00
|
|
|
|
2019-04-04 10:30:49 +11:00
|
|
|
const STATUS_OVERDUE = -1;
|
|
|
|
|
const STATUS_UNPAID = -2;
|
2019-04-28 20:25:18 +10:00
|
|
|
const STATUS_REVERSED = -7; //new for V2
|
2019-04-04 10:30:49 +11:00
|
|
|
|
2019-04-04 10:17:15 +11:00
|
|
|
public function company()
|
2018-11-20 15:36:56 +11:00
|
|
|
{
|
2019-04-04 10:17:15 +11:00
|
|
|
return $this->belongsTo(Company::class);
|
2018-11-20 15:36:56 +11:00
|
|
|
}
|
|
|
|
|
|
2019-04-04 10:17:15 +11:00
|
|
|
public function user()
|
2018-11-20 15:36:56 +11:00
|
|
|
{
|
2019-04-04 10:17:15 +11:00
|
|
|
return $this->belongsTo(User::class);
|
2018-11-20 15:36:56 +11:00
|
|
|
}
|
2019-04-04 10:30:49 +11:00
|
|
|
|
2018-10-22 23:04:37 +11:00
|
|
|
public function invitations()
|
|
|
|
|
{
|
2019-04-24 10:22:02 +10:00
|
|
|
return $this->hasMany(InvoiceInvitation::class);
|
2018-10-22 23:04:37 +11:00
|
|
|
}
|
2019-04-24 15:18:48 +10:00
|
|
|
|
|
|
|
|
public function client()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Client::class);
|
|
|
|
|
}
|
2019-04-28 15:31:32 +10:00
|
|
|
|
|
|
|
|
public function documents()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphMany(Document::class, 'documentable');
|
|
|
|
|
}
|
2018-10-15 23:40:34 +11:00
|
|
|
}
|