diff --git a/app/controllers/DashboardController.php b/app/controllers/DashboardController.php index 976351a0..14aca739 100644 --- a/app/controllers/DashboardController.php +++ b/app/controllers/DashboardController.php @@ -11,8 +11,6 @@ class DashboardController extends Controller { public function createIncidentAction() { $_incident = Input::get('incident'); - $_incident['user_id'] = Auth::user()->id; - $incident = Incident::create($_incident); return Redirect::back()->with('incident', $incident); @@ -31,6 +29,13 @@ class DashboardController extends Controller { ]); } + public function createComponentAction() { + $_component = Input::get('component'); + $component = Component::create($_component); + + return Redirect::back()->with('component', $component); + } + /** * Shows the incidents view. * @return \Illuminate\View\View diff --git a/app/models/Component.php b/app/models/Component.php index 302816e9..6e386d07 100644 --- a/app/models/Component.php +++ b/app/models/Component.php @@ -6,12 +6,12 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable use ValidatingTrait; protected $rules = [ - 'user_id' => 'required|integer', + 'user_id' => 'integer|required', 'name' => 'required', - 'status' => 'required|integer' + 'status' => 'integer' ]; - protected $fillable = ['name', 'description', 'status']; + protected $fillable = ['name', 'description', 'status', 'user_id']; /** * Lookup all of the incidents reported on the component. diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php index 93bc6995..43ce9a09 100644 --- a/app/routes/dashboard.php +++ b/app/routes/dashboard.php @@ -5,6 +5,8 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() { Route::post('/', 'DashboardController@createIncidentAction'); Route::get('components', ['as' => 'dashboard.components', 'uses' => 'DashboardController@showComponents']); + Route::post('components/create', 'DashboardController@createComponentAction'); + Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashboardController@showIncidents']); Route::get('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']); Route::get('notifications', ['as' => 'dashboard.notifications', 'uses' => 'DashboardController@showNotifications']); diff --git a/app/views/dashboard/components.blade.php b/app/views/dashboard/components.blade.php index aa0b9a3f..eda5c340 100644 --- a/app/views/dashboard/components.blade.php +++ b/app/views/dashboard/components.blade.php @@ -10,7 +10,6 @@