<?php

namespace App\Models\Traits;

trait FormattedAddressTrait
{
    /**
     * Combine the street and optionally a street suffix
     * e.g. Apt 1
     *
     * @since 1.0.0
     *
     * @return string
     */
    public function getAddressStreetAttribute(): string
    {
        $street = $this->street;
        if (! empty($this->unit)) {
            $street .= " {$this->unit}";
        }
        return $street;
    }

    /**
     * Combine the city and state together as a single line
     *
     * @since 1.0.0
     *
     * @return string
     */
    public function getCityStateAttribute(): string
    {
        return "{$this->city}, {$this->state}";
    }
}
