Created
May 10, 2020 11:55
-
-
Save araeuchle/d310a8626dc32f03e3963cfcd29a6371 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentController extends BaseController | |
{ | |
/** | |
* @var CommentService | |
*/ | |
private $commentService; | |
public function __construct(CommentService $commentService) | |
{ | |
parent::__construct(); | |
$this->commentService = $commentService; | |
$this->middleware(['comment']); // Only access to comments where user is attending to tours | |
} | |
public function list(Tour $tour) | |
{ | |
return CommentResource::collection($this->commentService->find($tour)); | |
} | |
public function add(CommentRequest $request, Tour $tour) | |
{ | |
$this->commentService->create($request, $tour); | |
return CommentResource::collection($this->commentService->find($tour)); | |
} | |
public function update(CommentRequest $request, Tour $tour, Comment $comment) | |
{ | |
$this->commentService->update($request, $comment); | |
return CommentResource::collection($this->commentService->find($tour)); | |
} | |
public function delete(Tour $tour, Comment $comment) | |
{ | |
$this->commentService->delete($comment); | |
return CommentResource::collection($this->commentService->find($tour)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment