payer-view.php
4 years ago
payment-by-record.php
4 years ago
payment-count-view.php
4 years ago
payment-view.php
4 years ago
payment-with-record-view.php
4 years ago
payment-with-record-view.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Gateways\Query_Views; |
| 5 | |
| 6 | use Jet_Form_Builder\Actions\Methods\Form_Record\Models\Record_Model; |
| 7 | use Jet_Form_Builder\Db_Queries\Exceptions\Sql_Exception; |
| 8 | use Jet_Form_Builder\Db_Queries\Query_Builder; |
| 9 | use Jet_Form_Builder\Exceptions\Query_Builder_Exception; |
| 10 | use Jet_Form_Builder\Gateways\Db_Models\Payment_Model; |
| 11 | use Jet_Form_Builder\Gateways\Db_Models\Payment_To_Record; |
| 12 | |
| 13 | class Payment_With_Record_View extends Payment_View { |
| 14 | |
| 15 | public function get_prepared_join( Query_Builder $builder ) { |
| 16 | parent::get_prepared_join( $builder ); |
| 17 | |
| 18 | $payments_to_records = ( new Payment_To_Record() )->create()::table(); |
| 19 | $payments = Payment_Model::table(); |
| 20 | $records = Record_Model::table(); |
| 21 | |
| 22 | $builder->join .= " |
| 23 | LEFT JOIN `{$payments_to_records}` ON 1=1 |
| 24 | AND `{$payments_to_records}`.`payment_id` = `{$payments}`.`id` |
| 25 | |
| 26 | LEFT JOIN `{$records}` ON 1=1 |
| 27 | AND `{$records}`.`id` = `{$payments_to_records}`.`record_id` |
| 28 | "; |
| 29 | } |
| 30 | |
| 31 | public function select_columns(): array { |
| 32 | return array_merge( |
| 33 | parent::select_columns(), |
| 34 | Record_Model::schema_columns( 'record' ) |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 |