This works fine:
$post->comments()->withTrashed()->get()->each->delete();
Since it does indeed delete the 6 rows the each
returns as a Collection.
However, this throws an exception:
$post->comments()->withTrashed()->get()->each->restore();
I noticed it also restored 1 row (the first row) in the database (the Collection has 6 rows).
Context: I use such code in an Observer to restore Comments when I restore a Post.
The following will throw the exact same exception InvalidArgumentException with message 'Illegale operator and value combination.'
:
$post->comments()->withTrashed()->where('deleted_at', '>=', $post->deleted_at)->get()->each->restore();
The where()
condition allows me to restore only comments softdeleted alongside the post's softdeletion (so that it does not also restore comments deleted by moderators prior to the whole post deletion).