Actions
4 months ago
AsyncData
1 year ago
Blocks
2 months ago
Controllers
3 months ago
DataTransferObjects
1 week ago
Exceptions
1 year ago
Factories
9 months ago
FormDesigns
11 months ago
FormPage
1 year ago
Listeners
1 year ago
Migrations
1 year ago
Models
10 months ago
OrphanedForms
1 year ago
Properties
2 months ago
Repositories
10 months ago
Routes
5 months ago
Rules
9 months ago
Shortcodes
2 years ago
V2
4 months ago
ValueObjects
1 year ago
ViewModels
2 months ago
resources
1 month ago
DonationFormDataQuery.php
11 months ago
DonationFormsAdminPage.php
1 year ago
DonationQuery.php
11 months ago
ServiceProvider.php
7 months ago
SubscriptionQuery.php
2 years ago
SubscriptionQuery.php
68 lines
| 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 |