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
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2019-04-24 02:22:02 +02:00
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-01-20 11:10:33 +01:00
|
|
|
use App\Utils\Traits\Inviteable;
|
2019-04-24 02:22:02 +02:00
|
|
|
use App\Utils\Traits\MakesDates;
|
2020-07-23 08:13:12 +02:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2020-03-29 14:22:14 +02:00
|
|
|
use Illuminate\Support\Carbon;
|
2019-04-24 02:22:02 +02:00
|
|
|
|
2023-03-08 08:33:42 +01:00
|
|
|
/**
|
|
|
|
* App\Models\QuoteInvitation
|
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property int $company_id
|
|
|
|
* @property int $user_id
|
|
|
|
* @property int $client_contact_id
|
|
|
|
* @property int $quote_id
|
|
|
|
* @property string $key
|
|
|
|
* @property string|null $transaction_reference
|
|
|
|
* @property string|null $message_id
|
|
|
|
* @property string|null $email_error
|
|
|
|
* @property string|null $signature_base64
|
|
|
|
* @property string|null $signature_date
|
|
|
|
* @property string|null $sent_date
|
|
|
|
* @property string|null $viewed_date
|
|
|
|
* @property string|null $opened_date
|
|
|
|
* @property int|null $created_at
|
|
|
|
* @property int|null $updated_at
|
|
|
|
* @property int|null $deleted_at
|
|
|
|
* @property string|null $signature_ip
|
|
|
|
* @property string|null $email_status
|
2023-08-11 06:18:58 +02:00
|
|
|
* @property \App\Models\Company $company
|
|
|
|
* @property \App\Models\ClientContact $contact
|
|
|
|
* @property mixed $hashed_id
|
|
|
|
* @property \App\Models\Quote $quote
|
|
|
|
* @property \App\Models\User $user
|
2023-03-08 08:33:42 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
|
|
|
* @method static \Database\Factories\QuoteInvitationFactory factory($count = null, $state = [])
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation newModelQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation newQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation onlyTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation query()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation withTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|QuoteInvitation withoutTrashed()
|
|
|
|
* @mixin \Eloquent
|
|
|
|
*/
|
2019-04-24 02:22:02 +02:00
|
|
|
class QuoteInvitation extends BaseModel
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
use MakesDates;
|
2020-01-20 11:10:33 +01:00
|
|
|
use Inviteable;
|
2020-07-23 08:13:12 +02:00
|
|
|
use SoftDeletes;
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-12-17 23:40:15 +01:00
|
|
|
protected $fillable = [
|
|
|
|
'id',
|
|
|
|
'client_contact_id',
|
|
|
|
];
|
|
|
|
|
2020-07-26 07:12:40 +02:00
|
|
|
protected $with = [
|
|
|
|
'company',
|
|
|
|
'contact',
|
|
|
|
];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-07-16 13:01:39 +02:00
|
|
|
protected $touches = ['quote'];
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-01-19 03:45:24 +01:00
|
|
|
public function getEntityString(): string
|
|
|
|
{
|
|
|
|
return 'quote';
|
|
|
|
}
|
|
|
|
|
2019-12-17 23:40:15 +01:00
|
|
|
public function entityType()
|
|
|
|
{
|
|
|
|
return Quote::class;
|
|
|
|
}
|
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
/**
|
2023-09-05 02:49:16 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
*/
|
2023-09-05 02:49:16 +02:00
|
|
|
public function quote(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Quote::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
2023-06-07 05:53:38 +02:00
|
|
|
/**
|
2023-09-05 02:49:16 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2023-06-07 05:53:38 +02:00
|
|
|
*/
|
2023-09-05 02:49:16 +02:00
|
|
|
public function entity(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2023-06-07 05:53:38 +02:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Quote::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
/**
|
2023-09-05 02:49:16 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
*/
|
2023-09-05 02:49:16 +02:00
|
|
|
public function contact(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
{
|
2020-02-15 10:01:15 +01:00
|
|
|
return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed();
|
2019-04-24 02:22:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-05 02:49:16 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
*/
|
2023-09-05 02:49:16 +02:00
|
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-05 02:49:16 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
*/
|
2023-09-05 02:49:16 +02:00
|
|
|
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-04-24 02:22:02 +02:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function signatureDiv()
|
|
|
|
{
|
|
|
|
if (! $this->signature_base64) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sprintf('<img src="data:image/svg+xml;base64,%s"></img><p/>%s: %s', $this->signature_base64, ctrans('texts.signed'), $this->createClientDate($this->signature_date, $this->contact->client->timezone()->name));
|
|
|
|
}
|
2020-03-04 12:09:43 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function markViewed()
|
|
|
|
{
|
2020-03-04 12:09:43 +01:00
|
|
|
$this->viewed_date = Carbon::now();
|
|
|
|
$this->save();
|
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
}
|