From 7eab54e4a93c5a8054cfb574e2983227263b154c Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Thu, 14 Nov 2024 10:43:49 -0500 Subject: [PATCH] Update docs --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index d49feea8..262b966f 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,24 @@ Similarly, attempting to create a model with an empty ID will throw a `InvalidKe Visit::create(['id' => '']); ``` +If you're running a high traffic application that may encounter a race condition, you may +pass in `true` in the second argument to `create` to ignore the exception and delete the existing record: + +```php +Visit::create(['id' => 'custom-id']); + +// The existing model will be deleted. +Visit::create(['id' => 'custom-id'], force: true); +``` + +Similarly, you may pass in `true` into the `save` method to ignore the exception and delete the existing record: + +```php +(new Visit(['id' => 'custom-id'])->save(); + +(new Visit(['id' => 'custom-id']))->save(force: true); +``` + To change the name of the field in which the model key is stored, override the `key` property: ```php