Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_many_pivot with get_relate and where #294

Open
giorgosstab opened this issue Dec 3, 2019 · 1 comment
Open

has_many_pivot with get_relate and where #294

giorgosstab opened this issue Dec 3, 2019 · 1 comment

Comments

@giorgosstab
Copy link

giorgosstab commented Dec 3, 2019

hey avenir i am curious if it is possible to query articles_with_authors in your test controller with get_related = true in model pivot table but what happen if i have a status enum in authors and need only active authors in my query? @avenirer

@giorgosstab
Copy link
Author

giorgosstab commented Jan 22, 2020

my has many pivot

 $this->has_many_pivot['vehicles'] = array(
		    'foreign_model'=>'Vehicle_model',
		    'pivot_table'=>'customer_vehicles',
		    'local_key'=>'id',
		    'pivot_local_key'=>'customer_id', 
		    'pivot_foreign_key'=>'vehicle_id', 
		    'foreign_key'=>'id',
		    'get_relate'=> true
        );

And my print data

stdClass Object
(
    [id] => 1
    [name] => Giorgos Tsaxrelias
    [username] => giorgosstab
    [email] => [email protected]
    [phone] => 6985678134
    [password] => $2y$10$wgryeRnWTIV6S4f35NyJTedhwMFJ3sAR2kTHzkiRHosEW3o6bblCW
    [address] => TestAddress
    [status] => ACTIVE
    [created_at] => 2019-11-27 14:05:23
    [updated_at] => 2019-12-11 09:34:51
    [vehicles] => stdClass Object
        (
            [1] => stdClass Object
                (
                    [id] => 1
                    [license_plate] => AXZ 5461
                    [slug] => axz-5461
                    [color] => red
                    [notes] => Test Notes
                    [status] => INACTIVE
                    [created_at] => 2019-11-27 14:12:10
                    [updated_at] => 2019-11-28 11:34:40
                )

            [3] => stdClass Object
                (
                    [id] => 3
                    [license_plate] => ABE 5509
                    [slug] => abe-5509
                    [color] => red
                    [notes] => 
                    [status] => ACTIVE
                    [created_at] => 2019-11-28 09:16:09
                    [updated_at] => 2019-11-29 12:01:07
                )

        )

)

and i want only active vehicles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant