DennisHermannsen Posted November 5, 2018 Share Posted November 5, 2018 Hi, I'm trying to get the date for the latest invoice for a specific product, but I have no luck. Can anyone tell me where I go wrong? $invoiceid = Capsule::table('tblinvoiceitems')->where('relid', 'xxxx')->orderBy('duedate', 'desc')->first(); 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted November 5, 2018 Author Share Posted November 5, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 5, 2018 Share Posted November 5, 2018 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... $invoiceid = Capsule::table('tblinvoiceitems')->where('relid','xxxx')->where('type','Hosting')->orderBy('duedate','desc')->value('invoiceid'); 1 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted November 5, 2018 Author Share Posted November 5, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.