From 86a8bb66f35df59b5e4c1f523670bdee29ad82e3 Mon Sep 17 00:00:00 2001 From: "A. B. M. Mahmudul Hasan" Date: Wed, 2 Jul 2025 16:36:03 +0600 Subject: [PATCH] updated to add common functions --- src/Collection/BaseCollectionTrait.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Collection/BaseCollectionTrait.php b/src/Collection/BaseCollectionTrait.php index 1cb1ad2..1316700 100644 --- a/src/Collection/BaseCollectionTrait.php +++ b/src/Collection/BaseCollectionTrait.php @@ -29,6 +29,21 @@ public function __construct(array $data = []) $this->data = $data; } + /** + * Create a new instance of the collection from the given data. + * + * This method acts as a wrapper around the `make` method, + * allowing for the creation of a collection instance using + * the provided data. The data is processed to ensure it is + * in an array format suitable for the collection. + * + * @param mixed $data The data to initialize the collection with. + * @return static A new instance of the collection. + */ + public static function from(mixed $data): static + { + return static::make($data); + } /** * Create a new instance of the collection with the given data. @@ -46,7 +61,6 @@ public static function make(mixed $data): static return $instance; } - /** * Dynamically handle calls to methods on the collection. *