<?php 

defined('BASEPATH') or exit ('Direct script access not allowed');

require_once APPPATH . "core/My_Admin.php";

class Rewards extends My_Admin{

    public function __construct()
    {
        parent::__construct();
    }

    // * rewards list
    public function index(){

        $data['details'] = $this->cm->search_multiple_where([], 'DESC', 'id', 'referral_rewards_settings');

        $this->load->view('admin/includes/header', $data);
        $this->load->view('admin/rewards/view');
        $this->load->view('admin/includes/footer');

    }


    // * update reward entry
    public function update_rewards(){
        request_method('POST');

        $request = check_parameter([
            'user_type' => true,
            'reward_coins' => true
        ]);

        $upd = $this->cm->update_where(['reward_coins' => $request['reward_coins']], ['user_type' => $request['user_type']], 'referral_rewards_settings');

        if($upd){
            echo json_encode([
                'status' => '1',
                'message' => 'reward coins updated'
            ]);exit;
        }

        echo json_encode([
            'status' => '0',
            'message' => 'failed to update the data'
        ]);exit;

    }

}