即使它存在,也找不到我的班级

时间:2016-06-10 15:04:12

标签: codeigniter-3 ion-auth

这是错误:

致命错误:第4行的C:\ xampp \ htdocs \ ci-blog-master \ application \ modules \ admin \ controllers \ Settings.php中找不到类'Admin_Controller'    遇到PHP错误

严重性:错误

消息:未找到类'Admin_Controller'

文件名:controllers / Settings.php

行号:4

回溯:

这是我的代码:

Admin_controller.php

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

class Admin_Controller extends MY_Controller {

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

这是我的Settings.php

class Settings extends Admin_Controller {

    public function __construct(){
        parent::__construct();
        $this->allow_group_access(array('admin'));

        $this->load->model('Category');
        $this->data['parent_menu'] = 'post';
    }

    public function index(){
        $this->session->set_flashdata('message',message_box('Setting is the coming soon feature!','danger'));
        redirect('admin/posts/index');

        $config['base_url'] = site_url('admin/categories/index/');
        $config['total_rows'] = count($this->Category->find());
        $config['per_page'] = 10;
        $config["uri_segment"] = 4;

        $this->data['categories'] = $this->Category->find($config['per_page'], $this->uri->segment(4));

        $this->data['pagination'] = $this->bootstrap_pagination($config);
        $this->render('admin/categories/index');
    }

    public function add(){
        $this->form_validation->set_rules('name', 'name', 'required|is_unique[categories.name]');
        $this->form_validation->set_rules('status', 'status', 'required');

        if($this->form_validation->run() == true){
            $category = array(
                'name' => $this->input->post('name'),
                'status' => $this->input->post('status')
            );
            $this->Category->create($category);
            $this->session->set_flashdata('message',message_box('Category has been saved','success'));
            redirect('admin/categories/index');
        }

        $this->render('admin/categories/add');
    }

    public function edit($id = null){
        if($id == null){
            $id = $this->input->post('id');
        }

        $this->form_validation->set_rules('name', 'name', 'required');
        $this->form_validation->set_rules('status', 'status', 'required');

        if($this->form_validation->run() == true){
            $category = array(
                'name' => $this->input->post('name'),
                'status' => $this->input->post('status')
            );
            $this->Category->update($category, $id);
            $this->session->set_flashdata('message',message_box('Category has been saved','success'));
            redirect('admin/categories/index');
        }

        $this->data['category'] = $this->Category->find_by_id($id);

        $this->render('admin/categories/edit');
    }

    public function delete($id = null){
        if(!empty($id)){
            $this->Category->delete($id);
            $this->session->set_flashdata('message',message_box('Category has been deleted','success'));
            redirect('admin/categories/index');
        }else{
            $this->session->set_flashdata('message',message_box('Invalid id','danger'));
            redirect('admin/categories/index');
        }
    }

    public function update_multiple(){
        #test commit
        #test commit di branch sendiri
    }
}

1 个答案:

答案 0 :(得分:1)

您可以在MY_Controller.php文件中添加更多课程:

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

class MY_Controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function some_mycontr_method()
    {
        // appropriate code here
    }
}

class Admin_Controller extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function some_admin_method()
    {
        // appropriate code here
    }
}