Laravel 8 intersect($items)
intersect
方法返回给定集合中也存在的所有模型:
use App\Models\User;
$users = $users->intersect(User::whereIn('id', [1, 2, 3])->get());
intersect
方法返回给定集合中也存在的所有模型:
use App\Models\User;
$users = $users->intersect(User::whereIn('id', [1, 2, 3])->get());