/** * Runs the seeding operations. */ public function run() { $metrics = $this->getSeedData(); foreach ($metrics as $metric) { $this->metric->model()->create($metric); } }
/** * Returns a new metric grid. * * @return \Cartalyst\DataGrid\DataGrid */ public function grid() { $columns = ['id', 'name', 'symbol', 'created_at', 'user_id']; $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11]; $transformer = function (Metric $metric) { return ['id' => $metric->id, 'name' => $metric->name, 'symbol' => $metric->symbol, 'created_at' => $metric->created_at, 'created_by' => $metric->user ? $metric->user->full_name : 'None', 'view_url' => route('maintenance.metrics.show', [$metric->id])]; }; return $this->metric->grid($columns, $settings, $transformer); }
/** * Updates the specified metric. * * @param int|string $id * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function destroy($id) { $metric = $this->metric->model()->findOrFail($id); if ($metric->delete()) { $message = 'Successfully deleted metric.'; return redirect()->route('maintenance.metrics.index')->withSuccess($message); } else { $message = 'There was an issue deleting this metric. Please try again.'; return redirect()->route('maintenance.metrics.edit', [$id])->withSuccess($message); } }
/** * @param $view * * @return mixed */ public function compose(View $view) { $allMetrics = $this->metric->all()->lists('name', 'id')->toArray(); $allMetrics[null] = 'Select a Metric'; return $view->with('allMetrics', $allMetrics); }