Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save araeuchle/d310a8626dc32f03e3963cfcd29a6371 to your computer and use it in GitHub Desktop.
Save araeuchle/d310a8626dc32f03e3963cfcd29a6371 to your computer and use it in GitHub Desktop.
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