<?php

namespace App\Models;

use App\Models\State; 

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ZipcodeRange extends Model
{
    use HasFactory;
    
    /**
	 * Manually Define Table Name.  
	 * 
	 * @var string 
	 */
    protected $table = 'zipcoderange';

    /**
	 * Define Relationships that must always be loaded. 
	 * 
	 * @var array 
	 */
	protected $with = 
	[
		//...
	];

	/**
	 * Define attributes that are mass assignable. 
	 * 
	 * @var array 
	 */
    protected $fillable = 
    [
        'state_id',
        'zipcode',
        'city',
        'twomiles',
        'fivemiles',
        'tenmiles',
        'fifteenmiles',
        'twentymiles'
    ];

	/**
	 * Define attributes that should be hidden for arrays. 
	 * 
	 * @var array 
	 */
    protected $hidden = 
	[
		//...
    ];

	//** Accessors & Mutators */

	//...

	//** belongsTo, belongsToMany, hasOne, hasMany relationships */ 

	/**
	 * Fetch State belongsTo relationship 
	 * 
	 * // @return ? 
	 */
	public function state() // : ? 
	{
		return $this->belongsTo(
			related   : State::class,
			foreignKey: "state_id",
			ownerKey  : "id"
		);
	}
}
