Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
38 | 14 | public function findActive($isCoupon = 0) |
|
39 | { |
||
40 | 14 | $query = $this->model->where('status', 1); |
|
41 | |||
42 | 14 | if (2 != $isCoupon) { |
|
43 | 14 | $query = $query->where('coupon_based', $isCoupon); |
|
44 | } |
||
45 | |||
46 | return $query |
||
47 | 14 | ->where(function ($query) { |
|
48 | 14 | $query->whereNull('starts_at') |
|
49 | 14 | ->orWhere(function ($query) { |
|
50 | 14 | $query->where('starts_at', '<', Carbon::now()); |
|
51 | 14 | }); |
|
52 | 14 | }) |
|
53 | 14 | ->where(function ($query) { |
|
54 | 14 | $query->whereNull('ends_at') |
|
55 | 14 | ->orWhere(function ($query) { |
|
56 | 14 | $query->where('ends_at', '>', Carbon::now()); |
|
57 | 14 | }); |
|
58 | 14 | })->with('rules', 'actions')->get(); |
|
59 | } |
||
60 | } |
||
61 |