mardi 16 avril 2019

How to implement "where not" in laravel eloquent query builder

What is the laravel equivalent eloquent query builder for this mysql sql snippet:

select * from `posts` left join `user_post_interactions` on `posts`.`id` = `user_post_interactions`.`post_id` where `posts`.`user_id` = 10 and not (`user_post_interactions`.`interaction_name` = 'hide' and `user_post_interactions`.`user_id` = 10)

What I am doing is:

$this->posts()->leftJoin('user_post_interactions', 'posts.id', '=', 'user_post_interactions.post_id')
            ->where(function($q) {
                $q->where('user_post_interactions.interaction_name', '<>', 'hide')
                    ->where('user_post_interactions.user_id', '<>', 10);
            });

But this is not producing the result I expected



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire