repository = $kitchen_comment; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\KitchenBlog\Repositories\Criteria\KitchenCommentResourceCriteria::class); } /** * Display a list of kitchen_comment. * * @return Response */ public function index(KitchenCommentRequest $request) { return $this->repository ->setPresenter(\Litecms\KitchenBlog\Repositories\Presenter\KitchenCommentPresenter::class) ->paginate(); } /** * Display kitchen_comment. * * @param Request $request * @param Model $kitchen_comment * * @return Response */ public function show(KitchenCommentRequest $request, KitchenComment $kitchen_comment) { return $kitchen_comment->setPresenter(\Litecms\KitchenBlog\Repositories\Presenter\KitchenCommentListPresenter::class); ; } /** * Create new kitchen_comment. * * @param Request $request * * @return Response */ public function store(KitchenCommentRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('kitchen_blog::kitchen_comment.name')]); $code = 204; $status = 'success'; $url = guard_url('kitchen_blog/kitchen_comment/' . $kitchen_comment->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('kitchen_blog/kitchen_comment'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the kitchen_comment. * * @param Request $request * @param Model $kitchen_comment * * @return Response */ public function update(KitchenCommentRequest $request, KitchenComment $kitchen_comment) { try { $data = $request->all(); $kitchen_comment->update($data); $message = trans('messages.success.updated', ['Module' => trans('kitchen_blog::kitchen_comment.name')]); $code = 204; $status = 'success'; $url = guard_url('kitchen_blog/kitchen_comment/' . $kitchen_comment->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('kitchen_blog/kitchen_comment/' . $kitchen_comment->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the kitchen_comment. * * @param Model $kitchen_comment * * @return Response */ public function destroy(KitchenCommentRequest $request, KitchenComment $kitchen_comment) { try { $kitchen_comment->delete(); $message = trans('messages.success.deleted', ['Module' => trans('kitchen_blog::kitchen_comment.name')]); $code = 202; $status = 'success'; $url = guard_url('kitchen_blog/kitchen_comment/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('kitchen_blog/kitchen_comment/' . $kitchen_comment->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }