Skip to content

Commit

Permalink
Added show method for single comment
Browse files Browse the repository at this point in the history
  • Loading branch information
iooe committed Mar 21, 2019
1 parent c82f63a commit 50768ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Http/Controllers/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use tizis\laraComments\Http\Requests\GetRequest;
use tizis\laraComments\Http\Requests\ReplyRequest;
use tizis\laraComments\Http\Requests\SaveRequest;
use tizis\laraComments\Http\Requests\ShowRequest;
use tizis\laraComments\Http\Resources\CommentResource;
use tizis\laraComments\UseCases\CommentService;
use tizis\laraComments\UseCases\VoteService;
Expand Down Expand Up @@ -103,6 +104,17 @@ public function get(GetRequest $request): array
return $response;
}

/**
* @param Comment $comment
* @param Request $request
* @return array
*/
public function show(Comment $comment, Request $request): array
{
return [
'comment' => $request->input('raw') ? $comment : new CommentResource($comment)
];
}

/**
* Updates the message of the comment.
Expand Down
1 change: 1 addition & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Route::post('/', '\tizis\laraComments\Http\Controllers\CommentsController@store')->name('store');
Route::delete('/{comment}', '\tizis\laraComments\Http\Controllers\CommentsController@destroy')->name('delete');
Route::put('/{comment}', '\tizis\laraComments\Http\Controllers\CommentsController@update')->name('update');
Route::get('/{comment}', '\tizis\laraComments\Http\Controllers\CommentsController@show');
Route::post('/{comment}', '\tizis\laraComments\Http\Controllers\CommentsController@reply')->name('reply');
Route::post('/{comment}/vote', '\tizis\laraComments\Http\Controllers\VoteController@vote')->name('vote');
});
Expand Down

0 comments on commit 50768ad

Please sign in to comment.