A
A
Abc Edc2015-12-07 13:52:30
MySQL
Abc Edc, 2015-12-07 13:52:30

Why is notIn not working on a given selection in Laravel?

Tags::where('name', 'LIKE', '%' . $like . '%')
                ->whereNotIn('id', $deprecate)
                ->where(function ($q) use ($id) {
                    $q->whereHas('closure', function ($q) use ($id) {
                        $q->where('tags_closure.ancestor_id', '=', $id);
                    })->orWhere(function ($q) {
                        $q->where('is_sealed', 1);
                    });
                })
                ->with('closure')
                ->get();

->whereNotIn('id', $deprecate) doesn't want to work out into anything, although $deprecate is quite a valid array
. What's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-12-07
@gleber1

What is the output request?
maybe the problem will become clear there,
let's try this

$q = Tags::where('name', 'LIKE', '%' . $like . '%')
                ->whereNotIn('id', $deprecate)
                ->where(function ($q) use ($id) {
                    $q->whereHas('closure', function ($q) use ($id) {
                        $q->where('tags_closure.ancestor_id', '=', $id);
                    })->orWhere(function ($q) {
                        $q->where('is_sealed', 1);
                    });
                })
                ->with('closure');
$sql = $q->toSql();

var_dump($sql);

also write array $deprecate which

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question