File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,12 @@ public static function all($columns = [])
129
129
return static ::scan ($ columns );
130
130
}
131
131
132
+ public static function create (array $ fillables = [], array $ options = []){
133
+ $ instance = new static ($ fillables );
134
+ $ instance ->save ($ options );
135
+ return $ instance ;
136
+ }
137
+
132
138
/**
133
139
* Save the model to the database.
134
140
*
Original file line number Diff line number Diff line change @@ -431,6 +431,29 @@ public function it_can_save_new_instance()
431
431
$ user ->save ();
432
432
}
433
433
434
+ /** @test */
435
+ public function it_can_static_create_new_instance ()
436
+ {
437
+ $ params = [
438
+ 'TableName ' => 'User ' ,
439
+ 'Item ' => [
440
+ 'partition ' => [
441
+ 'S ' => 'p '
442
+ ]
443
+ ],
444
+ 'ConditionExpression ' => 'attribute_not_exists(#1) ' ,
445
+ 'ExpressionAttributeNames ' => [
446
+ '#1 ' => 'partition '
447
+ ]
448
+ ];
449
+
450
+ $ connection = $ this ->newConnectionMock ();
451
+ $ connection ->shouldReceive ('putItem ' )->with ($ params );
452
+ $ this ->setConnectionResolver ($ connection );
453
+
454
+ $ user = UserA::create (['partition ' => 'p ' ]);
455
+ }
456
+
434
457
/** @test */
435
458
public function it_cannot_save_new_instance_without_required_key ()
436
459
{
You can’t perform that action at this time.
0 commit comments