belongsTo(Customer::class); } /** * Get the URL to the contact's avatar. */ public function getAvatarUrlAttribute() { if ($this->avatar) { return asset('storage/' . $this->avatar); } // Return null if no avatar is set return null; } /** * Scope a query to order contacts with primary contacts first. */ public function scopePrimaryFirst($query) { return $query->orderBy('is_primary', 'desc'); } }