diff --git a/docs/traits/models.md b/docs/traits/models.md index 73b3c4b..91ae264 100644 --- a/docs/traits/models.md +++ b/docs/traits/models.md @@ -5,7 +5,7 @@ weight: 1 ## Config File -first, provide an array in your config file, contain the model class name as a keey, and its value will be the full path: +first, provide an array in your config file, contain the model class name as a key, and its value will be the full path: For example, let say you plugin needs two models, the user model and a Bookmark model: ```php diff --git a/src/Concerns/HasModels.php b/src/Concerns/HasModels.php index f9f1ba7..bdcaafe 100644 --- a/src/Concerns/HasModels.php +++ b/src/Concerns/HasModels.php @@ -18,11 +18,11 @@ public function getModels(): array return $this->models; } - public static function getModel(string $model): string + public static function getModel(string $model): ?string { return array_merge( config(static::get()->getId() . '.models'), (new static)::get()->getModels() - )[$model]; + )[$model] ?? null; } }