How to compare 2 'created_at' dates in Laravel 4.2 Mongodb
In my application, the user can view the image and click the Next or Previous button. Currently, the logic for pulling next / previous image urls is field based 'created_at'
. I am trying to select all documents from my collection where the date is 'created_at'
greater than the current value (viewed by the user). However, the first document returned has the same value 'created_at'
as my current resource field 'created_at'
.
Eloquent request:
$photos = Photo::where('_id', '!=', $this->_id)
->where('created_at', '>', $this->created_at)
->orderBy('created_at', 'ASC');
Using:
- Laravel 4.2
- Mongodb 2.6.10
Library - Library: jenssegers / mongodb 2. *
Any help would be greatly appreciated!
thank
source to share
I have one idea for your question ....
1) add seen_at column to photos table
2) onlcik function with update table value 'viewd_column' using date ('Ymd H: i: s'); via ajax when user clicks image or next button
3) compare created_at file with view_at as shown below.
u need a jquery onclick function here ... when the user views the image at the moment the value is stored in your table. If you created create_at column ... create another column, browsing now, you can update this table column when user click this original image. Now you can get click date from view_at column ... now compare date
$photos = Photo::where('_id', '!=', $this->_id)
->where('created_at', '>', $this->viewed_at)
->orderBy('created_at', 'ASC');
His help u .. thank u .. all the best .. if in doubt ask me .. i will help you ..
source to share