Cakephp new parts notification system

I am trying to create a cakephp site that has a notification system that informs people when they register the number of new items that they have.

Currently, I register a site every time a visitor registers on a site, but I'm not sure how I can compare dates / timestamps with each other in a search.

What the find should do is to return all the data with a newer time stamp compared to the previous registered users.

I'm not sure how to encode this / just trying to figure out how I can encode this. Any help or direction would be appreciated.

To make this simple a

user hasMany logIns

 logIns belongsTo user 

a user hasMany Invoices

 Invoices belongTo user user has id, name, account_id loggedin has id, created, user_id invoice has id, sender, receiver, created, account_id 
+4
source share
1 answer

You can use the usual comparison operators <and> with dates and dates.

  • > means after
  • <means "before"

To find invoices created after the login date for the CakePHP controller, you can write, for example:

 $previous_login = '2012-09-20'; # obtain from somewhere $new_invoices = $this->Invoice->find('all', array( # "created after previous login" 'conditions' => array('created >' => $previos_login) )); 
+2
source

Source: https://habr.com/ru/post/1435419/


All Articles