Laravel 8 whereInstanceOf() {#collection-method}
whereInstanceOf
方法根据给定的类来过滤集合:
use App\Models\User;
use App\Models\Post;
$collection = collect([
new User,
new User,
new Post,
]);
$filtered = $collection->whereInstanceOf(User::class);
$filtered->all();
// [App\Models\User, App\Models\User]