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