A php error was encountered severity: notice?

0


A PHP Error was encountered
Severity: Notice

Message: Undefined property: Argo::$Argo_model

Filename: controllers/Argo.php

Line Number: 31

Backtrace:

File: C:\xampp\htdocs\ArgoCentr\application\controllers\Argo.php
Line: 31
Function: _error_handler

File: C:\xampp\htdocs\ArgoCentr\index.php
Line: 315
Function: require_once
An uncaught Exception was encountered
Type: Error

Message: Call to a member function getArgo() on null

Filename: C:\xampp\htdocs\ArgoCentr\application\controllers\Argo.php

Line Number: 31

Backtrace:

File: C:\xampp\htdocs\ArgoCentr\index.php
Line: 315
Function: require_once
<?php 

defined('BASEPATH') OR exit('No direc script access allowed');

class Argo extends MY_Controller {

	public function __constract() {
		parent::__constract();
		$this->load->model('Argo_model');
	}

	public function index() {

		if(!$this->dx_auth->is_admin()) {
			show_404();
		}



		$this->data['title'] = 'Все Вездеходы';
		$this->data['new'] = $this->Argo_model->getNewArgo();
		$this->data['used'] = $this->Argo_model->getUsedArgo();

		$this->load->view('templates/header', $this->data);
		$this->load->view('argo/index', $this->data);
		$this->load->view('templates/footer');
	}


	public function view($slug = NULL) {
		$argo_slug = $this->Argo_model->getArgo($slug, false, false);

		if (empty($argo_slug)) {
			show_404();
		}

		$this->load->model('Comments_model');
		$this->data['comments'] = $this->Comments_model->getComments($argo_slug['id'], 100);

		$this->data['id'] = $argo_slug['id'];
		$this->data['slug'] = $argo_slug['slug'];
		$this->data['title'] = $argo_slug['name'];
		$this->data['poster'] = $argo_slug['poster'];
		$this->data['price'] = $argo_slug['price'];
		$this->data['descriptions_argo'] = $argo_slug['descriptions'];
		$this->data['category'] = $argo_slug['category_id'];

		$this->load->view('templates/header', $this->data);
		$this->load->view('argo/view', $this->data);
		$this->load->view('templates/footer');

	}

A PHP Error was encountered
Severity: Notice

Message: Undefined property: Argo::$Argo_model

Filename: controllers/Argo.php

Line Number: 31

Backtrace:

File: C:\xampp\htdocs\ArgoCentr\application\controllers\Argo.php
Line: 31
Function: _error_handler

File: C:\xampp\htdocs\ArgoCentr\index.php
Line: 315
Function: require_once
An uncaught Exception was encountered
Type: Error

Message: Call to a member function getArgo() on null

Filename: C:\xampp\htdocs\ArgoCentr\application\controllers\Argo.php

Line Number: 31

Backtrace:

File: C:\xampp\htdocs\ArgoCentr\index.php
Line: 315
Function: require_once
<h1><?php echo $title." "; ?>

  <?php if($this->dx_auth->is_admin()) { ?>

        <a href="/argo/edit/<?php echo $slug; ?>"><button type="button" class="btn btn-default">
        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></button></a>
  <?php   } ?>

</h1>
  <hr>


            <div class="col-sm-6 col-md-4">
              <div class="thumbnail">
                <a href="/argo/view/<?php echo $value['slug']; ?>">

                <img src="<?php echo $value['poster']; ?>" alt="<?php echo $value['name']; ?>"></a>
                <div class="caption">
                  цена: <span class="badge"><?php echo $price; ?></span>
                  описание: <span class="badge"><?php echo $descriptions; ?></span>
                  <p><button class="btn btn-warning btn-buy" id="2">Купить</button></p>
                </div>
              </div>
            </div>



  <div class="margin-8"></div>

  <h2>Описание <?php if ($category == 1) {echo 'нового вездехода ';}?><?php if ($category == 2) {echo 'вездехода с пробегом ';}?> <?php echo $title; ?></h2>
  <hr>

  <div class="well">
    <?php echo $descriptions_argo; ?>
  </div>

  <div class="margin-8"></div>

  <h2>Отзывы о <?php if ($category == 1) {echo 'новом вездеходе ';}?><?php if ($category == 2) {echo 'вездеходе с пробегом ';}?> <?php echo $title; ?></h2>
  </h2>
  <hr>

  <?php foreach ($comments as $key => $value): ?>
    <div class="panel panel-info">
      <div class="panel-heading"><i class="glyphicon glyphicon-user"></i> <span><?php echo getUserNameByID($value['user_id'])->username; ?></span> </div>
      <div class="panel-body">
        <?php echo $value['comment_text']; ?>
      </div>
    </div>
  <?php endforeach ?>
  
  <?php if ($this->dx_auth->is_logged_in()): ?>

    <?php  $this->session->set_flashdata('redirect', $this->uri->uri_string()); ?>
  

  <form action="/argo/comment/" method="post">
    <input class="hidden" type="input" name="user_id" value="<?php echo $this->dx_auth->get_user_id(); ?>">
    <input class="hidden" type="input" name="argo_id" value="<?php echo $id; ?>">

    <div class="form-group">
      <textarea class="form-control" name="comment_text" placeholder="ваш комментарий"></textarea>
    </div>

    <button class="btn btn-lg btn-warning pull-right">отправить</button>
  </form>

  <?php endif ?>

  <?php if (!$this->dx_auth->is_logged_in()): ?>

    <br>
    <p>Чтобы оставить комментарий, войдите или зарегистрируйтесь!</p>

  <?php endif ?>
codeigniter

3 ответов

1

Как называется и выглядит файл Argo_model и есть ли в нем метод getArgo?

1
class Argo extends MY_Controller {

	public function __constract() {

Ошибка в слово __constract(), нужно писать __construct()

0
<?php  

class Argo_model extends CI_Model {
	public function __construct() {
		$this->load->database();
	}

	public function getArgo($slug = FALSE, $limit, $type = 1) {

		if ($slug === FALSE) {
			$query = $this->db
				->where('category_id', $type)
				->order_by('add_date', 'desc')
				->limit($limit)
				->get('argo');
			return $query->result_array();
		}
		$query = $this->db->get_where('argo', array('slug' => $slug));
		return $query->row_array();
	}
Sign up or Log in to write an answer