Hi,
Thanks. I have shared the code.
namespace PhalconRest\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
use Phalcon\Mvc\Collection as Collection;;
class ModelBase extends Collection {
public function initialize() {
$softDelete = new SoftDelete([
'field' => 'is_deleted',
'value' => 1
]);
$this->addBehavior($softDelete);
}
}
Below is the error log.,
[Mon Jan 21 18:35:09.754977 2019] [php7:error] [pid 5791] [client 103.253.168.194:30040] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Phalcon\\Mvc\\Collection::addBehavior() must implement interface Phalcon\\Mvc\\Collection\\BehaviorInterface, instance of Phalcon\\Mvc\\Model\\Behavior\\SoftDelete given in /var/www/html/test/admin/backend/api/models/ModelBase.php:17\nStack trace:\n#0 /var/www/html/thanthiram/admin/backend/api/models/ModelBase.php(17): Phalcon\\Mvc\\Collection->addBehavior(Object(Phalcon\\Mvc\\Model\\Behavior\\SoftDelete))\n#1 [internal function]: PhalconRest\\Models\\ModelBase->initialize()\n#2 [internal function]: Phalcon\\Mvc\\Collection\\Manager->initialize(Object(PhalconRest\\Models\\User))\n#3 [internal function]: Phalcon\\Mvc\\Collection->__construct()\n#4 /var/www/html/test/admin/backend/api/controllers/UserController.php(111): Phalcon\\Mvc\\Collection::find()\n#5 [internal function]: PhalconRest\\Controllers\\UserController->listuser()\n#6 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->__call('listuser', Array)\n#7 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->callMethod('listuser', Array, NU in /var/www/html/test/admin/backend/api/models/ModelBase.php on line 17