Hi,
I am just starting with Phalcon. I have created a simple model called "Reminders" which is mapped to a MySQL table reminders. A reminder has quite a few parameters including id, accout, type, and much more.
I am trying to build a simple REST API to add reminders to my table.
For adding a reminder I am using this route:
$app->post('/api/reminders/add/{type}', function($type) use ($app) {
$reminder = new Reminders();
$reminder->type = $type;
$reminder->account = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab';
$reminder->id = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaannn';
$reminder->recurrence_type = '1';
if ($reminder->save() == false) {
echo "Umh, We can't store reminders right now: \n";
foreach ($reminder->getMessages() as $message) {
echo $message, ".\n";
}
} else {
echo "Great, a new reminder was saved successfully!";
}
});
Unfortunately when I am doing a POST https://192.168.41.104:55000//api/reminders/add/2 The reminder is not added to the DB and I am getting:
Umh, We can't store reminders right now: locked is required.
Can anyone tell me what is "locked is required." ? how can I resolve this issue?
For info Reminders.php, looks like this:
<?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Message,
Phalcon\Mvc\Model\Validator\InclusionIn,
Phalcon\Mvc\Model\Validator\Uniqueness;
class Reminders extends Model
{
public $id;
public $account;
public $type;
public $activated;
public $deleted;
public $to;
public $from;
public $replyto;
public $title;
public $subject;
public $body;
public $cc;
public $bcc;
public function initialize()
{
$this->setSource("reminders"); // set correponding MySQL table
}
}
?>