Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. // trait Tax
  4. trait Tax
  5. {
  6. protected function calculate($value, $days)
  7. {
  8. return $value * .2 + (.03 * $days * $value);
  9. }
  10. }
  11.  
  12. trait Date
  13. {
  14. protected function diff()
  15. {
  16. return ;// todo: diff in days between two dates
  17. }
  18.  
  19. protected function today()
  20. {
  21. return date('Y-m-d'); // todo: something better then this
  22. }
  23. }
  24.  
  25. // class Bill
  26. class Bill extends Model
  27. {
  28. use Tax;
  29.  
  30. function save($data)
  31. {
  32. $data->tax = $this->calculate($data->value, $this->diff($data->payment, $this->today()));
  33.  
  34. parent::save($data);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement