mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
127 lines
2.6 KiB
PHP
127 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
/**
|
|
* Class ExpenseCategory.
|
|
*/
|
|
class Proposal extends EntityModel
|
|
{
|
|
use SoftDeletes;
|
|
use PresentableTrait;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $dates = ['deleted_at'];
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $presenter = 'App\Ninja\Presenters\ProposalPresenter';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'private_notes',
|
|
'html',
|
|
'css',
|
|
];
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
//protected $presenter = 'App\Ninja\Presenters\ProjectPresenter';
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getEntityType()
|
|
{
|
|
return ENTITY_PROPOSAL;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getRoute()
|
|
{
|
|
return "/proposals/{$this->public_id}";
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function account()
|
|
{
|
|
return $this->belongsTo('App\Models\Account');
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function invoice()
|
|
{
|
|
return $this->belongsTo('App\Models\Invoice')->withTrashed();
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function invitations()
|
|
{
|
|
return $this->hasMany('App\Models\ProposalInvitation')->orderBy('proposal_invitations.contact_id');
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function proposal_invitations()
|
|
{
|
|
return $this->hasMany('App\Models\ProposalInvitation')->orderBy('proposal_invitations.contact_id');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function proposal_template()
|
|
{
|
|
return $this->belongsTo('App\Models\ProposalTemplate')->withTrashed();
|
|
}
|
|
|
|
public function getDisplayName()
|
|
{
|
|
return $this->invoice->invoice_number;
|
|
}
|
|
|
|
public function getLink($forceOnsite = false, $forcePlain = false)
|
|
{
|
|
$invitation = $this->invitations->first();
|
|
|
|
return $invitation->getLink('proposal', $forceOnsite, $forcePlain);
|
|
}
|
|
|
|
public function getHeadlessLink()
|
|
{
|
|
return sprintf('%s?phantomjs=true&phantomjs_secret=%s', $this->getLink(true, true), env('PHANTOMJS_SECRET'));
|
|
}
|
|
|
|
public function getFilename($extension = 'pdf')
|
|
{
|
|
$entityType = $this->getEntityType();
|
|
|
|
return trans('texts.proposal') . '_' . $this->invoice->invoice_number . '.' . $extension;
|
|
}
|
|
}
|
|
|
|
Proposal::creating(function ($project) {
|
|
$project->setNullValues();
|
|
});
|
|
|
|
Proposal::updating(function ($project) {
|
|
$project->setNullValues();
|
|
});
|