1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00
invoiceninja/app/models/Contact.php

69 lines
1.2 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
class Contact extends Eloquent
{
protected $softDelete = true;
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()
{
return $this->belongsTo('Client');
}
2013-12-01 08:33:17 +01:00
public function getLastLogin()
2013-11-26 13:45:07 +01:00
{
if ($this->last_login == '0000-00-00 00:00:00')
{
return '---';
}
else
{
2013-12-01 08:33:17 +01:00
return $this->last_login->format('m/d/y h:i a');
2013-11-26 13:45:07 +01:00
}
}
2013-11-26 22:45:10 +01:00
public function getFullName()
{
$fullName = $this->first_name . ' ' . $this->last_name;
if ($fullName == ' ')
{
2013-11-29 13:09:21 +01:00
return 'Guest';
2013-11-26 22:45:10 +01:00
}
else
{
return $fullName;
}
}
2013-11-29 13:09:21 +01:00
public function getDetails()
{
$str = '';
if ($this->first_name || $this->last_name)
{
$str .= '<b>' . $this->first_name . ' ' . $this->last_name . '</b><br/>';
}
if ($this->email)
{
$str .= '<i class="fa fa-envelope" style="width: 20px"></i>' . HTML::mailto($this->email, $this->email) . '<br/>';
}
if ($this->phone)
{
$str .= '<i class="fa fa-phone" style="width: 20px"></i>' . $this->phone;
}
if ($str)
{
$str = '<p>' . $str . '</p>';
}
return $str;
}
2013-11-26 13:45:07 +01:00
}