repository = $blacklist; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Blacklist\Repositories\Criteria\BlacklistResourceCriteria::class); } /** * Display a list of blacklist. * * @return Response */ public function index(BlacklistRequest $request) { return $this->repository ->setPresenter(\Bixo\Blacklist\Repositories\Presenter\BlacklistPresenter::class) ->paginate(); } /** * Display blacklist. * * @param Request $request * @param Model $blacklist * * @return Response */ public function show(BlacklistRequest $request, Blacklist $blacklist) { return $blacklist->setPresenter(\Bixo\Blacklist\Repositories\Presenter\BlacklistListPresenter::class); ; } /** * Create new blacklist. * * @param Request $request * * @return Response */ public function store(BlacklistRequest $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('blacklist::blacklist.name')]); $code = 204; $status = 'success'; $url = guard_url('blacklist/blacklist/' . $blacklist->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('blacklist/blacklist'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the blacklist. * * @param Request $request * @param Model $blacklist * * @return Response */ public function update(BlacklistRequest $request, Blacklist $blacklist) { try { $data = $request->all(); $blacklist->update($data); $message = trans('messages.success.updated', ['Module' => trans('blacklist::blacklist.name')]); $code = 204; $status = 'success'; $url = guard_url('blacklist/blacklist/' . $blacklist->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('blacklist/blacklist/' . $blacklist->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the blacklist. * * @param Model $blacklist * * @return Response */ public function destroy(BlacklistRequest $request, Blacklist $blacklist) { try { $blacklist->delete(); $message = trans('messages.success.deleted', ['Module' => trans('blacklist::blacklist.name')]); $code = 202; $status = 'success'; $url = guard_url('blacklist/blacklist/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('blacklist/blacklist/' . $blacklist->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); } }