File tree 1 file changed +37
-3
lines changed
1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,51 @@ public function __construct(DynamoDbClientInterface $dynamoDb)
32
32
$ this ->attributeFilter = $ dynamoDb ->getAttributeFilter ();
33
33
}
34
34
35
- public function saved ($ model )
35
+ private function saveToDynamoDb ($ model )
36
36
{
37
37
$ attrs = $ model ->attributesToArray ();
38
- // $this->attributeFilter->filter($attrs);
38
+
39
39
try {
40
40
$ this ->dynamoDbClient ->putItem ([
41
41
'TableName ' => $ model ->getDynamoDbTableName (),
42
42
'Item ' => $ this ->marshaler ->marshalItem ($ attrs ),
43
43
]);
44
44
} catch (Exception $ e ) {
45
- Log::info ($ e );
45
+ Log::error ($ e );
46
46
}
47
47
}
48
+
49
+ private function deleteFromDynamoDb ($ model )
50
+ {
51
+ $ key = [$ model ->getKeyName () => $ model ->getKey ()];
52
+
53
+ try {
54
+ $ this ->dynamoDbClient ->deleteItem ([
55
+ 'TableName ' => $ model ->getDynamoDbTableName (),
56
+ 'Key ' => $ this ->marshaler ->marshalItem ($ key ),
57
+ ]);
58
+ } catch (Exception $ e ) {
59
+ Log::error ($ e );
60
+ }
61
+ }
62
+
63
+ public function created ($ model )
64
+ {
65
+ $ this ->saveToDynamoDb ($ model );
66
+ }
67
+
68
+ public function updated ($ model )
69
+ {
70
+ $ this ->saveToDynamoDb ($ model );
71
+ }
72
+
73
+ public function deleted ($ model )
74
+ {
75
+ $ this ->deleteFromDynamoDb ($ model );
76
+ }
77
+
78
+ public function restored ($ model )
79
+ {
80
+ $ this ->saveToDynamoDb ($ model );
81
+ }
48
82
}
You can’t perform that action at this time.
0 commit comments