DonationFormsRepository.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationForms\Repositories; |
| 4 | |
| 5 | use Give\Donations\ValueObjects\DonationMetaKeys; |
| 6 | use Give\Framework\Database\DB; |
| 7 | |
| 8 | /** |
| 9 | * @since 2.19.0 |
| 10 | */ |
| 11 | class DonationFormsRepository |
| 12 | { |
| 13 | /** |
| 14 | * @param int $formId |
| 15 | * |
| 16 | * @return int |
| 17 | */ |
| 18 | public function getFormDonationsCount(int $formId): int |
| 19 | { |
| 20 | return DB::table('posts') |
| 21 | ->leftJoin('give_donationmeta', 'ID', 'donation_id') |
| 22 | ->where('meta_key', DonationMetaKeys::FORM_ID) |
| 23 | ->where('meta_value', $formId) |
| 24 | ->count(); |
| 25 | } |
| 26 | } |
| 27 |