<?php

class Newsletter_model extends CI_Model
{
    public function email_exists($email)
    {
        $query = $this->db->get_where('newsletter_subscribers', ['email' => $email]);
        return $query->num_rows() > 0;
    }

    public function save_subscription($dataArr)
    {
        return $this->db->insert('newsletter_subscribers', [
            'email' => $dataArr['email'],
            'location_name' => $dataArr['location_name'],
            'subscribed_at' => date('Y-m-d H:i:s')
        ]);
    }
}