2019-04-24 02:22:02 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-04-24 02:22:02 +02:00
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-10-05 23:46:47 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
2020-10-05 13:32:56 +02:00
|
|
|
use App\Utils\Traits\Inviteable;
|
|
|
|
use App\Utils\Traits\MakesDates;
|
2019-04-24 02:22:02 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-10-05 13:32:56 +02:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2019-04-24 02:22:02 +02:00
|
|
|
|
|
|
|
class RecurringInvoiceInvitation extends BaseModel
|
|
|
|
{
|
2020-10-05 13:32:56 +02:00
|
|
|
use MakesDates;
|
|
|
|
use SoftDeletes;
|
|
|
|
use Inviteable;
|
|
|
|
|
2020-07-23 05:55:11 +02:00
|
|
|
protected $fillable = ['client_contact_id'];
|
|
|
|
|
2020-07-16 13:01:39 +02:00
|
|
|
protected $touches = ['recurring_invoice'];
|
|
|
|
|
2020-10-20 02:53:54 +02:00
|
|
|
protected $with = [
|
|
|
|
'company',
|
|
|
|
'contact',
|
|
|
|
];
|
|
|
|
|
2020-05-06 13:49:42 +02:00
|
|
|
public function getEntityType()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
return self::class;
|
2020-05-06 13:49:42 +02:00
|
|
|
}
|
|
|
|
|
2020-10-05 23:46:47 +02:00
|
|
|
public function entityType()
|
|
|
|
{
|
|
|
|
return RecurringInvoice::class;
|
|
|
|
}
|
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function recurring_invoice()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function contact()
|
|
|
|
{
|
2020-10-15 22:35:15 +02:00
|
|
|
return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed();
|
2019-04-24 02:22:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function company()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
}
|
|
|
|
|
2020-10-19 12:59:58 +02:00
|
|
|
public function markViewed()
|
|
|
|
{
|
2020-10-20 23:15:11 +02:00
|
|
|
$this->viewed_date = now();
|
2020-10-19 12:59:58 +02:00
|
|
|
$this->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function markOpened()
|
|
|
|
{
|
2020-10-20 23:15:11 +02:00
|
|
|
$this->opened_date = now();
|
2020-10-19 12:59:58 +02:00
|
|
|
$this->save();
|
|
|
|
}
|
2019-04-24 02:22:02 +02:00
|
|
|
|
|
|
|
}
|