Laravel : Delete all records that are not in array
You can use whereNotIn()
for that:
BoxDeliveryDate::whereNotIn('date', Request::get('dates'))->delete();
Note that this will not trigger any model events nor will it work with soft delete. Also, depending on the format of dates
you might have to format the array before passing it to whereNotIn()
.
Also I believe it should be Request::input('dates')
but it's possible that both actually works...