namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Mailer\Email;
use Cake\Filesystem\Folder;
use Cake\Filesystem\File;
use Cake\Controller\Controller;
class CustomComponent extends Component {
function __construct($prompt = null) {
}
function uploadImageBanner($tmp_name, $name, $path, $imgWidth) {
$user_id = $this->getController()->getRequest()->getSession()->read('Auth.User.id'); **// get error here**
//code here
//
}
}
This is my component code
Can you check what is the issue.
It’s not something specific to components. In general, in PHP, when you create a class that extends another class, and you have a __construct function, your function should take all the same parameters as the parent’s __construct function does, and then you do parent::__construct(...) with all the parameters in the … spot.