2016-06-10 4 views
0

Это ошибка:Он не находит мой класс, даже если она существует

Фатальная ошибка: Class 'Admin_Controller' не найден в C: \ XAMPP \ HTDOCS \ CI-блог-мастер \ приложения \ Modules \ админ \ контроллеры \ settings.php в строке 4 PHP-обнаружена ошибка

Серьезность: Ошибка

Сообщение: Class 'Admin_Controller' не найден

Имя файла: контроллеры/settings.php

Порядковый номер: 4

Backtrace:

И вот мой код:

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 
    } 
} 
+0

Просто подумал, но вы попробовали: класс Admin_controller расширяет MY_Controller – Joe

ответ

0

Вы можете разместить больше классов в 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 
    } 
} 
Смежные вопросы