| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\DonationForms; |
| 4 |
|
| 5 |
use Give\Framework\QueryBuilder\QueryBuilder; |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 3.12.0 |
| 9 |
*/ |
| 10 |
class SubscriptionQuery extends QueryBuilder |
| 11 |
{ |
| 12 |
/** |
| 13 |
* @since 3.12.0 |
| 14 |
*/ |
| 15 |
public function __construct() |
| 16 |
{ |
| 17 |
$this->from('give_subscriptions'); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* @since 3.12.0 |
| 22 |
*/ |
| 23 |
public function form($formId) |
| 24 |
{ |
| 25 |
$this->where('product_id', $formId); |
| 26 |
return $this; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* @since 3.12.0 |
| 32 |
*/ |
| 33 |
public function forms(array $formIds) |
| 34 |
{ |
| 35 |
$this->whereIn('product_id', $formIds); |
| 36 |
return $this; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* @since 3.12.0 |
| 41 |
*/ |
| 42 |
public function between($startDate, $endDate) |
| 43 |
{ |
| 44 |
$this->whereBetween( |
| 45 |
'created', |
| 46 |
date('Y-m-d H:i:s', strtotime($startDate)), |
| 47 |
date('Y-m-d H:i:s', strtotime($endDate)) |
| 48 |
); |
| 49 |
return $this; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* @since 3.12.0 |
| 54 |
*/ |
| 55 |
public function sumInitialAmount() |
| 56 |
{ |
| 57 |
return $this->sum('initial_amount'); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* @since 3.12.0 |
| 62 |
*/ |
| 63 |
public function countDonors() |
| 64 |
{ |
| 65 |
return $this->count('DISTINCT customer_id'); |
| 66 |
} |
| 67 |
} |
| 68 |
|