I have created a custom module and I want to inject my model in a constructor , but when I inject the model class then my controller stops working.
namespace DD\Reservations\Controller\Url;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\Action;
use DD\Reservations\Model\QuoteReservation;
use Psr\Log\LoggerInterface;
class TestResponse extends Action{
private $logger;
public function __construct(
Context $context,
// QuoteReservation $quoteReservation,
LoggerInterface $logger
)
{
$this->logger = $logger;
parent::__construct($context);
}
public function execute()
{
echo 'This is from test response';
$this->logger->debug('This is debug from test response');
}
}
If i uncomment the commented line from constructor my controller won't display the echo message anymore , neither the log message.
This is my model file:
<?php
namespace DD\Reservations\Model;
use Magento\Framework\Model\AbstractModel;
class QuoteReservation extends AbstractModel{
protected function _construct()
{
$this->_init(\DD\Reservations\Model\ResourceModel\QuoteReservation::class);
}
}