2

How do I add an IN clause in laravel with backpack?

This is what I am looking for:

$this->crud->addClause('where', 'customer_id', 'in', [1,3,5,6,7]);`

Should translate into something like this:

select * from customer where customer_id in (1,3,5,6,7);
ldam
  • 4,412
  • 6
  • 45
  • 76
  • Welcome to Stack Overflow! I edited the title to specify exactly what you are looking for, and so others can find it easily. I also indented your code by 4 spaces so that it is rendered as code. You can read [here](https://stackoverflow.com/editing-help) for more information on formatting. – ldam Oct 15 '18 at 14:18

2 Answers2

2

Just use whereIn instead of where, backpack-for-laravel is ready for that:

$this->crud->addClause('whereIn', 'customer_id', [1,3,5,6,7]);
António Almeida
  • 9,620
  • 8
  • 59
  • 66
0

select * from customer whereIn (customer_id ,$array);

bing
  • 1
  • No, its not that case, iam using a package called backpack, and inside the controller crud I have to use his features to filter data. its not only laravel. – Guilherme Schmidt Oct 18 '18 at 13:42