Check variable is a Laravel collection

In general, you can check simply using:

use Illuminate\Support\Collection;

....
if($variable instanceof Collection) {
....
}

In fact, we are checking whether the $variableis a Collection-object or not.

Another example:

We know that Illuminate\Database\Eloquent\Collection extends from Illuminate\Support\Collection

$record = User::all();
dump($record instanceof \App\User); // returns false
dump($record instanceof \Illuminate\Database\Eloquent\Collection); // returns true