<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class NotifyEmail extends Model
{
    /**
     * @var string
     */
    protected $table = 'notify_emails';

    /**
     * @var string[]
     */
    protected $fillable = [
     	'views',
     	'name',
        'customer_name',
     	'email',
        'domains_expired'
    ];

    /**
     * @var string[]
     */
    protected $casts = [
        'domains_expired' => 'array'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function domains()
    {
        return $this->belongsToMany(Domain::class, 'domains_notify_emails', 'notify_email_id', 'domain_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function visits()
    {
        return $this->hasMany(RenewPageVisit::class, 'notify_email_id');
    }

}
