Hi,
I am getting the below error. I guess I am missing something. Can you please suggest.
ModelBase
namespace PhalconRest\Models;
use Phalcon\Mvc\Collection as Collection;
use Phalcon\Mvc\Collection\Behavior\SoftDelete;
abstract class ModelBase extends Collection {
public function initialize() {
$this->addBehavior(new SoftDelete(
array(
'field' => 'is_deleted',
'value' => 1
)
));
}
}
StatusCode Model
namespace PhalconRest\Models\Utils;
use \PhalconRest\Models\ModelBase as ModelBase;
class StatusCode extends ModelBase {
public function getSource() {
return 'status_code';
}
public function metaData() {
return [
'code' => 'varchar',
'message' => 'varchar'
];
}
public function beforeValidationOnCreate() {
$this->is_deleted = 0;
$this->created_on = date('Y-m-d H:i:s');
}
}
In the Controller,
public function getMessageSuccess($code) {
$status = StatusCode::findFirst([['code' => $code]]);
return [ 'code' => $status->code, 'message' => $status->message, 'status' => 'fine' ];
}
[Sun Jan 27 09:10:07.135427 2019] [php7:notice] [pid 29834] [client 103.253.168.198:27029] RuntimeException: Call to undefined method \x01::rewind() in /var/www/html/test/admin/backend/api/controllers/RESTController.php:61\nStack trace:\n#0 [internal function]: Phalcon\\Mvc\\Collection::_getResultset(Array, Object(PhalconRest\\Models\\Utils\\StatusCode), Object(Phalcon\\Db\\Adapter\\MongoDB\\Database), true)\n#1 /var/www/html/test/admin/backend/api/controllers/RESTController.php(61): Phalcon\\Mvc\\Collection::findFirst(Array)\n#2 /var/www/html/test/admin/backend/api/controllers/Business/ServicesController.php(17): PhalconRest\\Controllers\\RESTController->getMessageSuccess('MES01')\n#3 [internal function]: PhalconRest\\Controllers\\Business\\ServicesController->serviceslist()\n#4 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->__call('serviceslist', Array)\n#5 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->callMethod('serviceslist', Array, NULL)\n#6 /var/www/html/test/admin/backend/api/config/init.php(86): Phalcon\\Mvc\\Micro->handle()\n#7 /var/www/html/test/admin/backend/api/index.php(15): require('/var/www/html/t...')\n#8 {main}
[Sun Jan 27 09:10:07.135483 2019] [php7:notice] [pid 29834] [client 103.253.168.198:27029] #0 [internal function]: Phalcon\\Mvc\\Collection::_getResultset(Array, Object(PhalconRest\\Models\\Utils\\StatusCode), Object(Phalcon\\Db\\Adapter\\MongoDB\\Database), true)\n#1 /var/www/html/test/admin/backend/api/controllers/RESTController.php(61): Phalcon\\Mvc\\Collection::findFirst(Array)\n#2 /var/www/html/test/admin/backend/api/controllers/Business/ServicesController.php(17): PhalconRest\\Controllers\\RESTController->getMessageSuccess('MES01')\n#3 [internal function]: PhalconRest\\Controllers\\Business\\ServicesController->serviceslist()\n#4 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->__call('serviceslist', Array)\n#5 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->callMethod('serviceslist', Array, NULL)\n#6 /var/www/html/test/admin/backend/api/config/init.php(86): Phalcon\\Mvc\\Micro->handle()\n#7 /var/www/html/test/admin/backend/api/index.php(15): require('/var/www/html/t...')\n#8 {main}