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