You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wish I could call the $this of the controller in the business model. What's the solution?
I want to write only basic access logic in the controller, and business logic in the business model Events
controller like this
namespace App\Controllers;
use App\Events\MyEvent;
class My extends \CodeIgniter\Controller {
protected $helpers = ['common', 'url'];
public function __construct(...$params) {
parent::__construct(...$params);
$this->mydate = 'test';
$this->db = \Config\Database::connect();
$this->db->initialize();
$this->form = \Config\Services::validation();
$this->myEvent = new MyEvent();
}
public function index() {
return $this->myEvent->getTest();
}
}
events like this
use App\Events;
class MyEvent {
public function getTest() {
// How can I use the $this in the controller here?
// Such as: $this->db->table('')....
// $this->form->withRequest($this->request)->run()...
// $this->mydate
}
}
What do I do?
The text was updated successfully, but these errors were encountered:
I wish I could call the $this of the controller in the business model. What's the solution?
I want to write only basic access logic in the controller, and business logic in the business model Events
controller like this
events like this
What do I do?
The text was updated successfully, but these errors were encountered: