<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Add_fav extends CI_Controller {

	
	public function __construct()
        {
                parent::__construct();
                $this->load->library('session');
                $this->load->model('admin/Add_fav_model');
                if(!isset($_SESSION['admin'])){redirect('admin/Login');}
        }

	

	public function index()
	{
		$data['data'] = $this->Add_fav_model->get_all();
		$this->load->view('admin/header');
		$this->load->view('admin/add-fav', $data);
		$this->load->view('admin/footer');
	}

	public function insert()
	{
		// $slug = preg_replace('/[^a-z0-9]+/i', '-', trim(strtolower($patr)));
		$data = $this->Add_fav_model->db_insert();
		if($data == 1){
			$this->session->set_flashdata("success"," Data sucessfully Saved.");
				redirect('admin/Add_fav');
		}else{
			$this->session->set_flashdata("error"," Data Not Insert.");
				redirect('admin/Add_fav');
		}
	}

	
}
