<?php
namespace Datacake\Core\Models;

use Datacake\Core\ORM\Eloquent\Model;
use Datacake\Core\Models\IspRedirectCity;
use Datacake\Core\Models\IspCity;
class IspRedirect extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'from_page_id',
        'to_page_id'
    ];

    public function from_page()
    {
        return $this->hasOne('Datacake\Core\ORMore\ORM\WP\Post','from_page_id');
    }

    public function to_page()
    {
        return $this->hasOne('Datacake\Core\ORMore\ORM\WP\Post','to_page_id');
    }

    /**
     * Get all of the posts for the country.
     */
    public function cities()
    {
        $ispRedirectCity = new IspRedirectCity();
        return $this->belongsToMany('Datacake\Core\Models\IspCity', $ispRedirectCity->getTable(),'redirect_id','city_id');
    }

}