belongsTo('App\Account'); } /** * Assigns a default value just in case the sort order is empty. * * @param string $value * @return string */ public function getContactsSortOrderAttribute($value) { return ! empty($value) ? $value : 'firstnameAZ'; } /** * Indicates if the layout is fluid or not for the UI. * @return string */ public function getFluidLayout() { if ($this->fluid_container == 'true') { return 'container-fluid'; } else { return 'container'; } } /** * @return string */ public function getMetricSymbol() { if ($this->metric == 'fahrenheit') { return 'F'; } else { return 'C'; } } /** * Get users's full name. The name is formatted according to the user's * preference, either "Firstname Lastname", or "Lastname Firstname". * * @return string */ public function getNameAttribute() { $completeName = ''; if ($this->name_order == 'firstname_first') { $completeName = $this->first_name; if (! is_null($this->last_name)) { $completeName = $completeName.' '.$this->last_name; } } else { if (! is_null($this->last_name)) { $completeName = $this->last_name; } $completeName = $completeName.' '.$this->first_name; } return $completeName; } /** * Gets the currency for this user. * * @return BelongsTo */ public function currency() { return $this->belongsTo(Currency::class); } /** * Set the contact view preference. * * @param string $preference */ public function updateContactViewPreference($preference) { $this->contacts_sort_order = $preference; $this->save(); } }