diff --git a/app/controllers/DashIncidentController.php b/app/controllers/DashIncidentController.php index 04ce212f..d42c62cb 100644 --- a/app/controllers/DashIncidentController.php +++ b/app/controllers/DashIncidentController.php @@ -24,6 +24,27 @@ class DashIncidentController extends Controller { ]); } + /** + * Shows the add incident template view. + * @return \Illuminate\View\View + */ + public function showAddIncidentTemplate() { + return View::make('dashboard.incident-template')->with([ + 'pageTitle' => 'Add Incident Template - Dashboard', + ]); + } + + /** + * Creates a new incident template. + * @return \Illuminate\Http\RedirectResponse + */ + public function createIncidentTemplateAction() { + $_template = Input::get('template'); + $template = IncidentTemplate::create($_template); + + return Redirect::back()->with('template', $template); + } + /** * Creates a new incident. * @return \Illuminate\Http\RedirectResponse diff --git a/app/models/IncidentTemplate.php b/app/models/IncidentTemplate.php index 19c2fc76..82b7dc93 100644 --- a/app/models/IncidentTemplate.php +++ b/app/models/IncidentTemplate.php @@ -7,8 +7,12 @@ class IncidentTemplate extends Eloquent { protected $rules = [ 'name' => 'alpha|required', - 'slug' => 'alpha_dash|required', - 'template' => 'required' + 'template' => 'required', + ]; + + protected $fillable = [ + 'name', + 'template', ]; /** @@ -18,7 +22,7 @@ class IncidentTemplate extends Eloquent { public static function boot() { parent::boot(); - self::on('saving', function($template) { + self::saving(function($template) { $template->slug = Str::slug($template->name); }); } diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php index f8b17559..f9e33be1 100644 --- a/app/routes/dashboard.php +++ b/app/routes/dashboard.php @@ -16,6 +16,8 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() { Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashIncidentController@showIncidents']); Route::get('incidents/add', ['as' => 'dashboard.incidents.add', 'uses' => 'DashIncidentController@showAddIncident']); Route::post('incidents/add', 'DashIncidentController@createIncidentAction'); + Route::get('incidents/template', ['as' => 'dashboard.incident-template', 'uses' => 'DashIncidentController@showAddIncidentTemplate']); + Route::post('incidents/template', 'DashIncidentController@createIncidentTemplateAction'); // Metrics Route::get('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']); diff --git a/app/views/dashboard/incident-template.blade.php b/app/views/dashboard/incident-template.blade.php new file mode 100644 index 00000000..073ea13b --- /dev/null +++ b/app/views/dashboard/incident-template.blade.php @@ -0,0 +1,37 @@ +@extends('layout.dashboard') + +@section('content') +