<?php namespace App\Controllers\Admin;

class Config extends AdminController
{
	private $mObj;
	
	public function __construct(){		
        $this->mObj = model('App\Models\Admin\ConfigModel');
		$this->menu_id =22;
    }
	
	public function edit(){
		$this->allowed('is_edit');

		$data['form_heading'] = "Config Edit";
		if($this->request->getMethod() === 'post'){
			$rules = $this->get_validation_rules();
			if ($this->validate($rules)) { 
				$data_in = $this->get_column_values();
				$this->mObj->update($data_in,1);
				$this->notify_success('Record Updated Successfully');
				return redirect()->to(get_admin_path('config/edit'));
			}
		}else{
			$data['update_data'] = $this->mObj->get(1);
		}
		//$data['footer_includes'] = ['crop_type_add_edit_js'];	
		echo $this->view_inner_template('config_add_edit',$data);
	}
	
	private function get_column_values(){
		$data['member_registration_amount'] = $this->request->getPost('member_registration_amount');
		$data['welcome_video'] = $this->request->getPost('welcome_video');
		return $data;
	}
	
	private function get_validation_rules($crop_type_id=""){
		$rules['member_registration_amount'] = ['label'=>'Amount', 'rules' => 'trim|required'];
		$rules['welcome_video'] = ['label'=>'Welcome', 'rules' => 'trim'];
		return $rules;
	}
}