2018-07-10 12:15:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Email extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Email types
|
|
|
|
*/
|
|
|
|
const TYPE_WORK = 'work';
|
|
|
|
const TYPE_HOME = 'home';
|
|
|
|
const TYPE_OTHER = 'other';
|
|
|
|
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attributes which are not fillable using fill() method
|
|
|
|
*/
|
|
|
|
protected $guarded = ['id', 'customer_id'];
|
|
|
|
|
|
|
|
/**
|
2018-07-14 03:23:37 +02:00
|
|
|
* Get email's customer
|
2018-07-10 12:15:58 +02:00
|
|
|
*/
|
|
|
|
public function customer()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Customer');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sanatize email address
|
|
|
|
* @param string $email
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function sanatizeEmail($email)
|
|
|
|
{
|
|
|
|
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
|
|
|
|
$email = strtolower($email);
|
|
|
|
|
|
|
|
return $email;
|
|
|
|
}
|
|
|
|
}
|