4

In my application the user can view an image and click on the 'next' or 'previous' photo button. Currently, the logic for pulling the next / previous image urls is based on the 'created_at' field. I am trying to pick all documents from my collection where the 'created_at' date is greater than the current resource's (being viewed by the user) value. However, the first document that is returned has the same 'created_at' value as my current resource's 'created_at' field.

Eloquent Query:

$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: jenssegers/mongodb 2.*

Any help will be much appreciated!

Thank you

chridam
  • 100,957
  • 23
  • 236
  • 235
Anuj
  • 41
  • 2

1 Answers1

0

i have one idea to your question....

1)add viewed_at column in photo table

2)onlcik function with update table value 'viewd_column' using date('Y-m-d H:i:s'); via ajax when user click image or next button

3)compare the created_at with viewed_at like below query

u need jquery onclick function here...for when user view the image that time the value stored in your table ..if u have created_at column...create another one column viewed_at now u can update that table column when user click that source image..then now u can get the click date from viewed_at column... now compare both date

$photos = Photo::where('_id', '!=', $this->_id)
             ->where('created_at', '>',  $this->viewed_at)
             ->orderBy('created_at', 'ASC');  

Its help to u.. thank u .. all the best.. if u have doubt ask to me.. i will help u..