If there is a way to check in laravel 7 if given var is collection of (Specific) models?
I tried
gettype($collectionVar)
and it returns ‘object’ string value...
Thanks!
If there is a way to check in laravel 7 if given var is collection of (Specific) models?
I tried
gettype($collectionVar)
and it returns ‘object’ string value...
Thanks!
You can take the first Model in the collection and check the instance type
use App\Models\Specific
if ($collection->first() instanceof Specific) {
// code here
}