Hey I am making my first use of command bus design pattern and I have a **PostController**
and a **ShowPosts**
Job.. I use this code to return all my posts in index method in controller.
$this->dispatch(new ShowPosts());
and in my job ShowPosts , in handle method ::
$posts = Post::latest()->with('comments.user','values')->paginate(5);
if(!$posts) {
return response()->json('there is no post',404);
}
but I can not return any data in my job.. how can I return data in my job? what id I have a job for returning posts from a user, what is in that job? Thank you
Aucun commentaire:
Enregistrer un commentaire