![]() |
Call to a member function getDestaque() on null [SOLVED] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Call to a member function getDestaque() on null [SOLVED] (/showthread.php?tid=83566) |
Call to a member function getDestaque() on null [SOLVED] - clovissardinha - 10-05-2022 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 code ![]() 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(); } } RE: Call to a member function getDestaque() on null - captain-sensible - 10-07-2022 [/font] in Code: public function getDestaque() RE: Call to a member function getDestaque() on null - clovissardinha - 10-07-2022 Tanks, solved. RE: Call to a member function getDestaque() on null - InsiteFX - 10-08-2022 Please add [SOLVED] to your Title when the problem is solved. I did it for you this time. Thank you, Forum Moderators. |