diff --git a/README.md b/README.md index ee0cd7d..f513bfd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Nova Inline Relationship allows you to manage (add/edit/update/delete/reorder) a ## Requirements -This package requires Laravel Nova 4.0. +This package requires Laravel Nova 5.0. ## Installation diff --git a/src/Helpers/Fluent.php b/src/Helpers/Fluent.php index 79d03d9..8cfd802 100644 --- a/src/Helpers/Fluent.php +++ b/src/Helpers/Fluent.php @@ -14,8 +14,13 @@ class Fluent extends \Illuminate\Support\Fluent * * @return $this */ - public function fill(array $attributes) + public function fill($attributes) { + // Ensure attributes is an array for Laravel 12 compatibility + if (!is_array($attributes)) { + $attributes = (array) $attributes; + } + foreach ($attributes as $key => $value) { $attribute = Str::replace('->', '.', $key); diff --git a/src/NovaInlineRelationship.php b/src/NovaInlineRelationship.php index 5f5761a..6160296 100644 --- a/src/NovaInlineRelationship.php +++ b/src/NovaInlineRelationship.php @@ -91,7 +91,7 @@ public function sortUsing(string $sortUsing): self * * @return void */ - public function resolveForDisplay($resource, $attribute = null) + public function resolveForDisplay($resource, ?string $attribute = null): void { parent::resolveForDisplay($resource, $attribute); @@ -110,7 +110,7 @@ public function resolveForDisplay($resource, $attribute = null) * * @return void */ - public function resolve($resource, $attribute = null) + public function resolve($resource, ?string $attribute = null): void { parent::resolve($resource, $attribute); diff --git a/src/NovaInlineRelationshipRequest.php b/src/NovaInlineRelationshipRequest.php index b35ef9d..7abc1d9 100644 --- a/src/NovaInlineRelationshipRequest.php +++ b/src/NovaInlineRelationshipRequest.php @@ -55,7 +55,18 @@ public static function createFrom(Request $from, $to = null) try { $session = $from->getSession(); - $request->setLaravelSession($session); + + // Laravel 12 compatibility fix: Handle SymfonySessionDecorator properly + if ($session instanceof \Illuminate\Session\SymfonySessionDecorator) { + // Extract the underlying session store from the decorator + $reflector = new \ReflectionClass($session); + $storeProperty = $reflector->getProperty('store'); + $storeProperty->setAccessible(true); + $actualSession = $storeProperty->getValue($session); + $request->setLaravelSession($actualSession); + } else { + $request->setLaravelSession($session); + } } catch (SessionNotFoundException $exception) { // do nothing }