I am using Microsoft Visual Code for custom Joomla development. The below code is from one of the controller php file.
Public function savecontact(){
Joomla\CMS\Session\Session::checkToken() or die( 'Invalid Token' );
$model = $this->getModel('book');
if ($model->store()) {
$msg = Joomla\CMS\Language\Text::_( 'JSMS_BOOKV_BOOKSAVESUCCESS' );
$msg_type = "message";
} else {
$msg = Joomla\CMS\Language\Text::_( 'JSMS_BOOKV_BOOKSAVEFAIL' );
$msg_type = "error";
}
The above code is trying to use the method defined inside the model. Since the model is called as getModel('book')
Visual Code is not able to interpret the methods defined in the model and it is throwing error as Undefined method 'store'.
I understand this is not an actual error, it is only a problem in Visual Code display. To me it is annoying to see these type of errors in every controller file.
How this can be remediated so that Visual Code should not throw this as an error?