Adjustment.php 958 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018-06-27
  6. * Time: 12:36
  7. */
  8. namespace iBrand\Component\Discount\Test\Models;
  9. use iBrand\Component\Discount\Contracts\AdjustmentContract;
  10. use Illuminate\Database\Eloquent\Model;
  11. class Adjustment extends Model implements AdjustmentContract
  12. {
  13. protected $guarded=['id'];
  14. public function __construct(array $attributes = [])
  15. {
  16. $this->setTable(config('ibrand.app.database.prefix', 'ibrand_') . 'order_adjustment');
  17. parent::__construct($attributes);
  18. }
  19. /**
  20. * create a adjustment.
  21. *
  22. * @param $type
  23. * @param $label
  24. * @param $amount
  25. * @param $originId
  26. * @param $originType
  27. *
  28. * @return mixed
  29. */
  30. public function createNew($type, $label, $amount, $originId, $originType)
  31. {
  32. return new self(['type'=>$type,'label'=>$label,'amount'=>$amount,'origin_id'=>$originId,'origin_type'=>$originType]);
  33. }
  34. }