1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/Models/Invitation.php
2015-07-02 23:21:29 +03:00

53 lines
1.2 KiB
PHP

<?php namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
class Invitation extends EntityModel
{
use SoftDeletes;
protected $dates = ['deleted_at'];
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
public function contact()
{
return $this->belongsTo('App\Models\Contact')->withTrashed();
}
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
public function account()
{
return $this->belongsTo('App\Models\Account');
}
public function getLink()
{
if (!$this->account) {
$this->load('account');
}
$url = SITE_URL;
if ($this->account->subdomain) {
$parsedUrl = parse_url($url);
$host = explode('.', $parsedUrl['host']);
$subdomain = $host[0];
$url = str_replace("://{$subdomain}.", "://{$this->account->subdomain}.", $url);
}
return "{$url}/view/{$this->invitation_key}";
}
public function getName()
{
return $this->invitation_key;
}
}