sort($sortBy, $direction); } $metrics = $metrics->paginate(Binput::get('per_page', 20)); return $this->paginator($metrics, Request::instance()); } /** * Get a single metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function show(Metric $metric) { return $this->item($metric); } /** * Create a new metric. * * @return \Illuminate\Http\JsonResponse */ public function store() { try { $metric = execute(new CreateMetricCommand( Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type', 0), Binput::get('display_chart', true), Binput::get('places', 2), Binput::get('default_view', Binput::get('view', 1)), Binput::get('threshold', 5), Binput::get('order', 0), Binput::get('visible', 1) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); } /** * Update an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function update(Metric $metric) { try { $metric = execute(new UpdateMetricCommand( $metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type'), Binput::get('display_chart'), Binput::get('places'), Binput::get('default_view', Binput::get('view')), Binput::get('threshold'), Binput::get('order'), Binput::get('visible') )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); } /** * Delete an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function destroy(Metric $metric) { execute(new RemoveMetricCommand($metric)); return $this->noContent(); } }