-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Given the Schema Files -> FilesPaymentAgreements -> FilesPaymentAgreementsDetail, where Files is the master table, is it possible to add define a join for a field on table FilesPaymentAgreementsDetail?
I have tried these two things:
$joins = [
'FilesPaymentAgreementsDetail.PaymentDate' => [
'from_table' => 'FilesPaymentAgreements',
'from_col' => 'ID',
'to_table' => 'FilesPaymentAgreementsDetail',
'to_col' => 'ExID',
'to_value_column' => 'PaymentDate',
'to_clause' => function($q) {
$q->join('FilesPaymentAgreementsDetail', 'FilesPaymentAgreementsDetail.ExID', '=', 'FilesPaymentAgreements.ID');
},
],
];
$qbp = new \timgws\JoinSupportingQueryBuilderParser(['FilesPaymentAgreementsDetail.PaymentDate'], $joins);
dd($qbp->parse(request()->query_builder, DB::table('Files')->toSql());Gave me: select * from [Files] where exists (select 1 from [FilesPaymentAgreements] where FilesPaymentAgreements.ExID = Files.ID and [Inactive] = ?) and exists (select 1 from [FilesPaymentAgreements] where FilesPaymentAgreements.ExID = Files.ID and [PaymentMethodID] = ?)
$joins = [
'FilesPaymentAgreementsDetail.PaymentDate' => [
[
'from_table' => 'Files',
'from_col' => 'ID',
'to_table' => 'FilesPaymentAgreements',
'to_col' => 'ExID',
'to_value_column' => 'PaymentDate',
],
[
'from_table' => 'FilesPaymentAgreements',
'from_col' => 'ID',
'to_table' => 'FilesPaymentAgreementsDetail',
'to_col' => 'ExID',
'to_value_column' => 'PaymentDate',
],
],
];Gave me: "Undefined array key \"to_table\""
Metadata
Metadata
Assignees
Labels
No labels