Welcome Guest, Not a member yet? Register   Sign In
Call to a member function getDestaque() on null [SOLVED]
#1

(This post was last modified: 10-08-2022, 12:31 AM by InsiteFX.)

Please, I can't solve the problem. When I call the method it displays an error. Even if the method is empty. I didn't find any typos. codeigniter 4

This is the codeTonguelease, I can't solve the problem. When I call the method it displays an error. Even if the method is empty. I didn't find any typos. codeigniter 4

This is the code:

//controler
<?php

namespace App\Controllers;

use App\Models\DestaqueModel;

class Home extends BaseController{
    protected $destaqueModel;

public function __contruct(){  
   
    $this->destaqueModel= new DestaqueModel();

                            }

public function index()
    {

        $destaques=$this->destaqueModel
        ->getDestaque();
       
        //dd($destaques);
        return view('home/index');
    }
}


//model
<?php namespace app\Models;

use App\Models\BaseModel;
use CodeIgniter\Model;

class DestaqueModel extends BaseModel{ //class BaseModel extends Model { }
   
    protected $table="destaque";
    protected $useSoftDeletes='true';
    protected $deletedField='deleted_at';
    protected $createdField='created_at';
    protected $updatedField='updated_at';
   
    protected $useTimestamps='true';
   
    protected $beforeInsert = ['vinculaIdUsuario','geraChave'];
    protected $deforeDelete = [''];
   
    protected $allowedFields = [
        'usuario_id',
        'chave',
        'data_pgto',
        'data_inicio',
        'data_fim',
        'tipo'
    ];
    protected $validationRules = [
            'tipo' =>[
            'label'=>'Tipo',
            'rules'=>'required'
            ]
            ];

           /**
            * Busca os destaques entre o dia inicial e dia final
            */
   
    public function getDestaque()
        {      
            $this->select( "
               'id_destaque',
               'usuario_id',
               'chave',
               'data_pgto',
               'data_inicio',
               'data_fim',
               'tipo'   ");


return $this->findAll();
    }
   
       
}
Reply
#2

[/font]

in
Code:
public function getDestaque()
{

}

for starters
CMS CI4     I use Arch Linux by the way 

Reply
#3

Tanks, solved.
Reply
#4

(This post was last modified: 10-08-2022, 12:30 AM by InsiteFX.)

Please add [SOLVED] to your Title when the problem is solved. I did it for you this time.

Thank you, Forum Moderators.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB