add function view into PostsController.php