Added more database fields for contacts. Worked on popovers in customers view. #3
This commit is contained in:
+36
-3
@@ -11,14 +11,18 @@ class Contact extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
'is_primary',
|
||||
'salutation',
|
||||
'academic_title',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'job_title',
|
||||
'email',
|
||||
'phone',
|
||||
'position',
|
||||
'is_primary',
|
||||
'mobile_phone',
|
||||
'avatar',
|
||||
'online_accounts',
|
||||
'notes',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
@@ -38,7 +42,7 @@ public function getAvatarUrlAttribute()
|
||||
// Return null if no avatar is set
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scope a query to order contacts with primary contacts first.
|
||||
*/
|
||||
@@ -46,4 +50,33 @@ public function scopePrimaryFirst($query)
|
||||
{
|
||||
return $query->orderBy('is_primary', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the online accounts attribute.
|
||||
*
|
||||
* @param array $value
|
||||
* @return void
|
||||
*/
|
||||
public function setOnlineAccountsAttribute($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$value = json_decode($value, true);
|
||||
}
|
||||
|
||||
$this->attributes['online_accounts'] = json_encode([
|
||||
'platform' => $value['platform'] ?? '',
|
||||
'user_name' => $value['user_name'] ?? '',
|
||||
'url' => $value['url'] ?? ''
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the online accounts attribute.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOnlineAccountsAttribute()
|
||||
{
|
||||
return json_decode($this->attributes['online_accounts'], true) ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user