CouponApplication.php
3 years ago
CouponEntity.php
1 year ago
CouponFactory.php
3 years ago
CouponType.php
2 years ago
CouponUnit.php
3 years ago
index.php
3 years ago
CouponFactory.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Membership\Models\Coupon; |
| 4 | |
| 5 | use ProfilePress\Core\Membership\Models\FactoryInterface; |
| 6 | use ProfilePress\Core\Membership\Repositories\CouponRepository; |
| 7 | |
| 8 | class CouponFactory implements FactoryInterface |
| 9 | { |
| 10 | /** |
| 11 | * @param $data |
| 12 | * |
| 13 | * @return CouponEntity |
| 14 | */ |
| 15 | public static function make($data) |
| 16 | { |
| 17 | return new CouponEntity($data); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @param $id |
| 22 | * |
| 23 | * @return CouponEntity |
| 24 | */ |
| 25 | public static function fromId($id) |
| 26 | { |
| 27 | return CouponRepository::init()->retrieve(absint($id)); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @param $code |
| 32 | * |
| 33 | * @return CouponEntity |
| 34 | */ |
| 35 | public static function fromCode($code) |
| 36 | { |
| 37 | return CouponRepository::init()->retrieveByCode($code); |
| 38 | } |
| 39 | } |