When tapping on a Post item, it navigates to a Detail screen, and display data response from Detail Resource API
Detail Resource API pattern: "url
/restful_api/mobile/post/post_id
?access_token=token
"
Code of the API is implemented in method findOne() of PostApi class. ID parameter will be resolved automatically. The Resolver instance is a Helper class that helps extract or validate parameters from the request.
PostApi.php
Code Block |
---|
class PostApi extends AbstractResourceApi implements MobileAppSettingInterface
{
/.../
public function findOne($params)
{
$id = $this->resolver->resolveId($params);
// Todo: Loading data form database and build as resource
$post = new PostResource([
'post_id' => $id,
'title' => "Post's title example " . $id,
'description' => "Post's description " . $id,
'text' => "Post's Full Text " .$id
]);
return $this->success($post);
}
} |
The result of the Detail screens are as following images