diff --git a/composer.json b/composer.json index add4d78..da47e02 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "kiwilan/typescriptable-laravel", "description": "PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript. If you want to use some helpers with Inertia, you can install associated NPM package.", - "version": "1.11.31", + "version": "1.11.32", "keywords": [ "kiwilan", "laravel", diff --git a/src/Typed/Eloquent/Utils/EloquentRelation.php b/src/Typed/Eloquent/Utils/EloquentRelation.php index 06f5204..393ceaf 100644 --- a/src/Typed/Eloquent/Utils/EloquentRelation.php +++ b/src/Typed/Eloquent/Utils/EloquentRelation.php @@ -187,7 +187,11 @@ private function parseMorphModel(ReflectionMethod $method) $this->hasPivot = true; $this->phpType = $related; - $this->typescriptType = "App.Models.{$related}"; + + $tsModel = explode('\\', $related); + $this->pivotModel = $tsModel[count($tsModel) - 1]; + $this->typescriptType = 'App.Models.'.$tsModel[count($tsModel) - 1]; + if ($this->isArray) { $this->typescriptType .= '[]'; }