Jump to content

Sort by date and get latest


Recommended Posts

38 minutes ago, DennisMidjord said:

Nevermind, I figured it out. Results were returned as an object, so I had to to $invoiceid->invoiceid to show only the id of the invoice.

not that it matters now, but if you just want one particular value from a row, you can use value instead of first (which gives you the entire row)...

$invoiceid = Capsule::table('tblinvoiceitems')->where('relid','xxxx')->orderBy('duedate','desc')->value('invoiceid'); 

also, it might be more useful to add some more conditions to the query, e.g the same relid value might be used for domains and products, so you may need to specify the type in the query to ensure that you are identifying the correct invoice...

ZsEM9gh.png

$invoiceid = Capsule::table('tblinvoiceitems')->where('relid','xxxx')->where('type','Hosting')->orderBy('duedate','desc')->value('invoiceid'); 
Link to comment
Share on other sites

37 minutes ago, brian! said:

you can use value instead of first

Really? When I was messing with it, I did use value and it gave me the correct value from invoiceid, but I was just afraid that it wouldn't always work as intended. I only need the fvery first, and I thought that 'first' was the only way to achieve this.

Thanks for the advise! We're only using this for game hosting, so there's really only type of product, but I'll update it anyways just to be sure.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated