Guest User

Untitled

a guest
Nov 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. //IT SHOULD BE INSIDE YOUR MEHTOD
  5.  
  6. //get last record
  7. $record = RecordModel::latest()->first();
  8. $expNum = explode('-', $record->invoiceno);
  9.  
  10.  
  11. //check first day in a year
  12. if ( date('l',strtotime(date('Y-01-01'))) ){
  13. $nextInvoiceNumber = date('Y').'-0001';
  14. } else {
  15. //increase 1 with last invoice number
  16. $nextInvoiceNumber = $expNum[0].'-'. $expNum[1]+1;
  17. }
  18.  
  19.  
  20. //Now add New record into database
Add Comment
Please, Sign In to add comment