invoiceninja/app/Models/Contact.php

58 lines
1.2 KiB
PHP
Raw Normal View History

2015-03-18 09:39:03 +10:00
<?php namespace App\Models;
2015-03-17 07:45:25 +10:00
2015-03-31 21:50:58 +03:00
use HTML;
2015-03-31 12:38:24 +03:00
use Illuminate\Database\Eloquent\SoftDeletes;
2015-03-17 07:45:25 +10:00
class Contact extends EntityModel
{
2015-03-31 12:38:24 +03:00
use SoftDeletes;
protected $dates = ['deleted_at'];
2015-10-28 21:22:07 +02:00
protected $fillable = [
'first_name',
'last_name',
'email',
'phone',
'send_invoice',
];
2015-03-17 07:45:25 +10:00
public static $fieldFirstName = 'Contact - First Name';
public static $fieldLastName = 'Contact - Last Name';
public static $fieldEmail = 'Contact - Email';
public static $fieldPhone = 'Contact - Phone';
public function client()
{
2015-03-31 12:38:24 +03:00
return $this->belongsTo('App\Models\Client');
2015-03-17 07:45:25 +10:00
}
public function getPersonType()
{
return PERSON_CONTACT;
}
2015-07-02 23:21:29 +03:00
public function getName()
{
return $this->getDisplayName();
}
2015-03-17 07:45:25 +10:00
public function getDisplayName()
{
if ($this->getFullName()) {
return $this->getFullName();
} else {
return $this->email;
}
}
public function getFullName()
{
if ($this->first_name || $this->last_name) {
return $this->first_name.' '.$this->last_name;
} else {
return '';
}
}
}