How to return class name in collection instance in laravel?

Member

by addison , in category: PHP Frameworks , 8 months ago

How to return class name in collection instance in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , 8 months ago

@addison 

In Laravel, you can return the class name of a collection instance by using the get_class() function. Here's an example of how you can do this:

1
2
3
4
5
$collection = collect([1, 2, 3]);

$className = get_class($collection);

echo $className; // Output: IlluminateSupportCollection


This code snippet creates a collection instance using the collect() helper function, and then retrieves the class name of the collection using the get_class() function. The output will be the class name of the collection, which in this case is IlluminateSupportCollection.

Related Threads:

How to return data from mongodb collection in java?
How to select collection using it's name on shopify?
How to validate model object instance in laravel?
How to get element by class name in vue.js?
How to filter a laravel collection?
How to filter collection in laravel?