Skip to content

Commit

Permalink
Merge pull request #1 from lara-zeus/allow-nullable
Browse files Browse the repository at this point in the history
allow nullable model
  • Loading branch information
atmonshi authored Oct 17, 2024
2 parents 354f2c3 + 648e951 commit 8104dff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/traits/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/HasModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 8104dff

Please sign in to comment.