From cd28a1941e2053bfe8c4a54acf7a02eb2d3a96f7 Mon Sep 17 00:00:00 2001 From: Daniel Eisenhardt Date: Wed, 23 Feb 2022 07:29:22 +0100 Subject: [PATCH 1/2] created a MenuItem::attributesToArray() function to circumvent a new Eloquent changes which caused problems --- src/MenuItem.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/MenuItem.php b/src/MenuItem.php index ae32cb5..276eeec 100644 --- a/src/MenuItem.php +++ b/src/MenuItem.php @@ -222,6 +222,31 @@ public function toArray() return array_merge($this->attributesToArray(), $this->variablesToArray()); } + /** + * Convert the model's attributes to an array. + * + * @return array + */ + public function attributesToArray() + { + // If an attribute is a date, we will cast it to a string after converting it + // to a DateTime / Carbon instance. This is so we will get some consistent + // formatting while accessing attributes vs. arraying / JSONing a model. + $attributes = $this->addDateAttributesToArray( + $attributes = $this->getArrayableAttributes() + ); + + + // Here we will grab all of the appended, calculated attributes to this model + // as these attributes are not really in the attributes array, but are run + // when we need to array or JSON the model for convenience to the coder. + foreach ($this->getArrayableAppends() as $key) { + $attributes[$key] = $this->mutateAttributeForArray($key, null); + } + + return $attributes; + } + /** * Convert the object to its JSON representation. * From 9df026f5d020a6c5f6c554140c0cf90f4009e313 Mon Sep 17 00:00:00 2001 From: Daniel Eisenhardt Date: Wed, 23 Feb 2022 07:57:35 +0100 Subject: [PATCH 2/2] changed package name for composer publishing --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5c6e13f..db76dcd 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "rspeekenbrink/laravel-menu", + "name": "danieleisenhardt/laravel-menu", "description": "Simple menu generation in Laravel", "type": "library", "license": "MIT",