• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BaseController load, use model example

I have a model that performs some operations in my database. We'll call it "Somemodel". There's a method I want to use called "somemethod($value)" in the Somemodel model. I'd like to include this model and call that method in every controller. I know that I can modify the BaseController, and all my controllers should extend BaseController. Can someone show me an example of what that looks like? The documentation shows using a Session service.  So, what does the code look like to load one of my models?

// Do Not Edit This Line
parent::initController($request, $response, $logger);

// Preload any models, libraries, etc, here.
// E.g.:
// $this->session = \Config\Services::session();

$session = \Config\Services::session($config); // I like this!

// How do I load one of my models and use a method? What does that code look like?

Messages In This Thread
BaseController load, use model example - by MrPeterman - 09-18-2020, 08:50 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.