<?php
namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class StreetName
 *
 * @package App
 * @property string $name
 * @property string $type
*/
class StreetName extends Model
{
    use SoftDeletes;

    protected $fillable = ['name', 'type_id'];
    protected $hidden = [];

    /**
     * Set to null if empty
     * @param $input
     */
    public function setTypeIdAttribute($input)
    {
        $this->attributes['type_id'] = $input ? $input : null;
    }
    
    public function type()
    {
        return $this->belongsTo(StreetNameType::class, 'type_id')->withTrashed();
    }
    
}
