File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/Ushahidi/Modules/V5/Http/Controllers Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,24 @@ public function update(int $id, MessageRequest $request)
87
87
return $ this ->show ($ id );
88
88
}// end update
89
89
90
+ private function getPost (int $ id , ?array $ fields = null , ?array $ haydrates = null )
91
+ {
92
+ if (!$ fields ) {
93
+ $ fields = Post::ALLOWED_FIELDS ;
94
+ }
95
+ if (!$ haydrates ) {
96
+ $ haydrates = array_keys (Post::ALLOWED_RELATIONSHIPS );
97
+ }
98
+ $ find_post_query = new FindPostByIdQuery ($ id );
99
+ $ find_post_query ->addOnlyValues (
100
+ $ fields ,
101
+ $ haydrates ,
102
+ Post::ALLOWED_RELATIONSHIPS ,
103
+ Post::REQUIRED_FIELDS
104
+ );
105
+ return $ this ->queryBus ->handle ($ find_post_query );
106
+ }
107
+
90
108
/**
91
109
* Display the specified resource.
92
110
*
@@ -99,7 +117,7 @@ public function showPost(int $id)
99
117
$ message = $ this ->queryBus ->handle (new FetchMessageByIdQuery ($ id ));
100
118
$ this ->authorize ('show ' , $ message );
101
119
if ($ message ->post_id ) {
102
- $ post = $ this ->queryBus -> handle ( new FindPostByIdQuery ( $ message ->post_id , Post:: ALLOWED_FIELDS ) );
120
+ $ post = $ this ->getPost ( $ message ->post_id );
103
121
return new postResource ($ post );
104
122
}
105
123
throw new NotFoundException ("Post does not exist for this message " );
You can’t perform that action at this time.
0 commit comments