Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // trait Tax
- trait Tax
- {
- protected function calculate($value, $days)
- {
- return $value * .2 + (.03 * $days * $value);
- }
- }
- trait Date
- {
- protected function diff()
- {
- return ;// todo: diff in days between two dates
- }
- protected function today()
- {
- return date('Y-m-d'); // todo: something better then this
- }
- }
- // class Bill
- class Bill extends Model
- {
- use Tax;
- function save($data)
- {
- $data->tax = $this->calculate($data->value, $this->diff($data->payment, $this->today()));
- parent::save($data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement