Another thing we need to fix in our application is the fact that our dates don't mean anything. We have published and updated dates in our
posts table, which we are not using. Let's make sure we're setting those dates. Let's open up the
Posts.php file located at
app/model. We are going to add more code to the
initialize function of our Posts model, and we are going to use a behavior on our date fields. First, add this line of code after the first PHP tag:
Then, add the following lines of code to the
initialize function in this model:
$this->addBehavior(new Timestampable( array( 'beforeCreate' => array( 'field' => 'published', 'format' => 'Y-m-d H:i:s' ) ) )); $this->addBehavior(new ...