Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
YasserElgammal committed Apr 3, 2024
1 parent 262f151 commit 8762faa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/ApiCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function index()
{
$categories = Category::paginate(15);

return $this->retrieveReponse(data: CategoryResource::collection($categories));
return $this->retrieveResponse(data: CategoryResource::collection($categories));
}

public function show($id)
{
$category = Category::with('posts')->whereId($id)->firstOrFail();

return $this->retrieveReponse(data: CategoryResource::make($category));
return $this->retrieveResponse(data: CategoryResource::make($category));
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/ApiPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function index()
{
$posts = Post::with(['user:id,name', 'category:id,name', 'tags:id,name'])->whereStatus(true)->orderByDesc('id')->paginate(15);

return $this->retrieveReponse(data: PostResource::collection($posts));
return $this->retrieveResponse(data: PostResource::collection($posts));
}

public function show($id)
{
$post = Post::with(['user:id,name', 'category:id,name', 'tags:id,name', 'comments.user'])->whereId($id)->whereStatus(true)->firstOrFail();

return $this->retrieveReponse(data: PostResource::make($post));
return $this->retrieveResponse(data: PostResource::make($post));
}
}
4 changes: 2 additions & 2 deletions app/Traits/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

trait ApiResponse
{
public function retrieveReponse($message = null, mixed $data = null, $code = Response::HTTP_OK)
public function retrieveResponse($status = true, $message = null, mixed $data = null, $code = Response::HTTP_OK)
{
return $this->responseHandle(status: true, message: $message, data: $data, code: $code);
return $this->responseHandle(status: $status, message: $message, data: $data, code: $code);
}

private function responseHandle(bool $status, string $message = null, mixed $data = null, int $code)
Expand Down

0 comments on commit 8762faa

Please sign in to comment.