Skip to content

Commit d54bab2

Browse files
committed
add document for create() method
1 parent d9ab578 commit d54bab2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A DynamoDB based Eloquent model and Query builder for Laravel.
1616
+ [Retrieving all models](#retrieving-all-models)
1717
+ [Retrieving a model](#retrieving-a-model)
1818
+ [save()](#save)
19+
+ [create()](#create)
1920
+ [update()](#update)
2021
+ [delete()](#delete)
2122
+ [increment() / decrement()](#increment--decrement)
@@ -229,12 +230,21 @@ If the model has sort key and `sortKeyDefault` is defined:
229230
User::find('foo@bar.com'); // Partition key. sortKeyDefault will be used for Sort key.
230231
```
231232

233+
#### create()
234+
235+
```php
236+
$user = User::create([
237+
'email' => 'foo@bar.com',
238+
'type' => 'profile' // Sort key. If we don't specify this, sortKeyDefault will be used.
239+
]);
240+
```
241+
232242
#### save()
233243

234244
```php
235245
$user = new User([
236246
'email' => 'foo@bar.com',
237-
'type' => 'profile' // Sort key. If we don't specify this, sortKeyDefault will be used.
247+
'type' => 'profile'
238248
]);
239249

240250
$user->save();

src/Kitar/Dynamodb/Model/Model.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ public static function all($columns = [])
129129
return static::scan($columns);
130130
}
131131

132-
public static function create(array $fillables = [], array $options = []){
132+
/**
133+
* Save a new model and return the instance.
134+
*
135+
* @param array $fillables
136+
* @param array $options
137+
* @return \Kitar\Dynamodb\Model\Model|$this
138+
*/
139+
public static function create(array $fillables = [], array $options = [])
140+
{
133141
$instance = new static($fillables);
134142
$instance->save($options);
135143
return $instance;

0 commit comments

Comments
 (0)