summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Models/BaseModel.php12
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);
+ }
}