get_list_data($request); $fields = $this->get_list_fields(); return $this->view('list')->with([ 'title' => $this->_title, 'fields' => $fields, 'base_url' => $this->_base_url, 'items' => $values, 'buttons' => $this->get_list_buttons() ]); } protected function get_list_data(Request $request) { $data = $this->_basemodel->orderby('id', 'desc')->get(); $dd = []; foreach($data->toArray() as $d) { $dd[] = (object)$d; } return $dd; } public function form($type, $id = null) { $values = []; if($type == 'edit') { $values = $this->_basemodel->find($id); $values = (object) $values->toArray(); } $values = $this->_beforeform($type, $values); $fields = $this->get_form_fields($type, $values); //echo '
'; print_r($fields); exit;
        return $this->view('form')->with([
            'title' => $this->_title,
            'mode' => $type,
            'fields' => $fields,
            'base_url' => $this->_base_url,
            'item' => $values,
        ]);
    }

    public function save($type, $request ) {
        try {
            $data = $this->_beforesave($type, $request);
            //echo '
'; print_r($data); exit;
            if($type == 'edit') {
                $this->_basemodel->where('id', $data['id'])->update($data);
                $obj = $data['id'];
            } else {
                $obj = $this->_basemodel->create($data);
                $obj = $obj->id;
            }
            //$this->_aftersave($obj);
            return redirect($this->_base_url.'s')->withMessage('Successfully Saved !!!');
        } catch (Exception $e) {
            return redirect($this->_base_url.'s')->withError('Some Error occured! ');
        }
    }

    public function delete($id) {
        try {
            $this->_basemodel->where('id', $id)->delete();
            return redirect($this->_base_url.'s')->withMessage('Successfully Marked Deleted !!!');
        } catch (Exception $e) {
            return \Redirect::back()->withMessage('Some Error occured!');
        }
    }
}