<?php
namespace App;

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

/**
 * Class Street
 *
 * @package App
 * @property string $street_name
 * @property string $street_number
 * @property string $flat_number
 * @property string $discrict
 * @property-write mixed $discrict_id
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Street newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Street newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Street onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Street query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Query\Builder|\App\Street withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Street withoutTrashed()
 * @mixin \Eloquent
 */
class Street extends Model
{
    use SoftDeletes;

    protected $fillable = ['street_name', 'street_number', 'flat_number', 'discrict_id'];
    protected $hidden = [];
    
    

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