diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-25 17:29:15 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-10-30 21:13:56 +0100 |
commit | c4867811e26bc32798ba24dd701bc2c35d49b027 (patch) | |
tree | 18f89f31c47ec378e5dd11600ae7aba79bcc09e5 /src | |
parent | c9afc27ab9ea62269967df14a80581ed51ba6c71 (diff) |
BaseModel: Added findOrNew
Diffstat (limited to 'src')
-rw-r--r-- | src/Models/BaseModel.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Models/BaseModel.php b/src/Models/BaseModel.php index d5ded428..2367f5b6 100644 --- a/src/Models/BaseModel.php +++ b/src/Models/BaseModel.php @@ -36,4 +36,16 @@ abstract class BaseModel extends Model { return static::query()->find($id, $columns); } + + /** + * Find a model by its attributes or create a new one + * + * @param mixed $id + * @param array $columns + * @return static|Model + */ + public static function findOrNew($id, $columns = ['*']) + { + return static::query()->findOrNew($id, $columns); + } } |